> dput(head(final,10))
structure(list(Y = c(93.433, 104.456, 163.792, 125.249, 146.837,
78.196, 52.192, 191.33, 75.02, 145.785), X1 = c(5.9701, 9.3506,
9.718, 14.1317, 9.9278, 1.9318, 2.2236, 12.612, 13.8961, 8.1844
), X2 = c(6.047, 9.4063, 9.4967, 13.9422, 10.0581, 1.6575, 1.8749,
12.3052, 13.7316, 8.2732), X3 = c(8.1105, 8.365, 16.8862, 14.8049,
14.1477, 15.9753, 12.0362, 16.5604, 8.1691, 16.4479), x4 = c(1.70843,
0.34726, 4.76446, 2.19965, 2.80567, 7.58081, 5.59927, 3.56611,
-1.10324, 4.76204), x5 = c(1, 1, 1, 2, 1, 1, 3, 1, 2, 1)), row.names = c(NA,
10L), class = "data.frame")
x5 is my factor variable, which has type 1, 2, 3. Now I want to create x6 and x7 such that:
Types | x6 | x7 |
---|---|---|
type 1 | 0 | 0 |
type 2 | 1 | 0 |
type 3 | 0 | 1 |
How to do?