I've got a large data frame finaldata and i would like to produce a bunch of other smaller data frames explanatory1, explanatory2 e.t.c.... consisting of 10 columns each from finaldata
I'm trying to do this using a for loop but its throwing me an error attempt to apply non function
for(i in 1:length(finaldata)/10) {
nam <- paste("explanatory", i, sep = "")
assign(nam, finaldata[,10(i):10(i)+10])
}
I have also tried
for(i in 1:length(finaldata)/10){
assign(paste("explanatory",i,sep=""),finaldata[,10(i):10(i)+10])}
But this gave me the same error, from what I understand the error is being caused by my passing finaldata[,10(i):10(i)+10] as an argument to assign, but I don't see why it wouldn't work ina for loop, or be any different from passing finaldata[,10:10+10]
Any help would be greatly appreciated!
finaldatainto multiple data.frames, with columns 1:10, 11:20, 21:30, ..., respectively?