So I have a small problem in R. I have multiple data sets (data0, data1,...) and I want to do the following:
data01 <- data0[1:6,]
data02 <- data0[7:12,]
data11 <- data1[1:6,]
data12 <- data1[7:12,]
data21 <- data2[1:6,]
data22 <- data2[7:12,]
data31 <- data3[1:6,]
data32 <- data3[7:12,]
...etc
I would like to do this in a for loop like so:
for(i in 1:(some high number)){
datai1 <- datai[1:6,]
datai2 <- datai[7:12,]
}
I've tried messing around with assign()
and get()
, however I cannot make it work. I found something that might work in this question, however the difference is that here the variable d
should also change depending on the index. Any idea how I could make this work?