-3

I have the code:

i<-1
while(i<5)
{
  df+i <-data.frame()
  df+i<-c(i,i+1)
  i<-i+1

}

Instead of i numbers are expected. I want to create objects df1 ,df2, df3, etc.

I tried assign(paste("a", i, sep = ""), i)

but its not working.

  • i want data frame with different name in "LOOP" – user3050374 Dec 04 '13 at 15:34
  • @Joshua Ulrich above link is not my expected answer.. that gives only create data frame but not adding value in it data+i<-c(i,i+) is not possbile in above answer – user3050374 Dec 04 '13 at 15:58
  • No, it's not _exactly_ your expected answer, but getting your expected answer is trivial using the linked question. Sorry, but I expected you to do _some_ work. – Joshua Ulrich Dec 04 '13 at 17:01

1 Answers1

1

Try this:

for (i in 1:5){assign(paste("df",i,sep=""),data.frame())}
jlhoward
  • 58,004
  • 7
  • 97
  • 140