I'd like to write a loop that creates five new data sets in R, each one containing a different number of observations from an original data frame, df.
Here is my current code, it outputs the value of dfi as a string rather than the actual object ("df[4:42 + i]" instead of df[4:42 + i]).
for(i in 1:5)
{ nam <- paste("df",i, sep="")
assign(nam, eval(paste("df","[1:44 + ",i,",]", sep="")))
}
I'd like to return the df object when it loops, but I don't know how to do that. Any suggestions? Thank you very much in advance.