Let's say I am working with the following data frame:
Mydata <- data.frame(X1 = c(1,2,3,4,5,6,7,8,9,10),X2 = c(1,3,1,1,1,5,1,1,8,1),
X3 = c(1,2,3,4,5,6,7,8,9,10),X4 = c(1,3,1,1,1,5,1,1,8,1),
X5 = c(1,2,3,4,5,6,7,8,9,10),X6 = c(1,3,1,1,1,5,1,1,8,1),
X7 = c(1,2,3,4,5,6,7,8,9,10),X8 = c(1,3,1,1,1,5,1,1,8,1),
X9 = c(1,2,3,4,5,6,7,8,9,10),X10 = c(1,3,1,1,1,5,1,1,8,1),
X11 = c(1,2,3,4,5,6,7,8,9,10),X12 = c(1,3,1,1,1,5,1,1,8,1))
I want to split this data frame into three separate data frames, with columns X1 ~ X4 in one data frame, X5 ~ X8 in the second, and X9 ~ X12. How would I code this to continue this pattern for any number of columns?
See Question&Answers more detail:
os