[R] Copy dataframe for another

RMSOPS ricardosousa2000 at clix.pt
Fri Mar 9 11:31:19 CET 2012


Hello,

    the idea is to copy the d for df, with new results.

x<-data.frame(name="x1",pos=4,age=20)
x<-rbind(x,data.frame(name="x2",pos=5,age=20))
x<-rbind(x,data.frame(name="x3",pos=6,age=21))
x<-rbind(x,data.frame(name="x4",pos=7,age=24))
x<-rbind(x,data.frame(name="x5",pos=8,age=27))
x<-rbind(x,data.frame(name="x6",pos=9,age=26))
View(x)


d<-NULL
df<-NULL

for(r in 2: nrow(x))
{
  val_user<-x$name[[r]]
  pos<-x$pos[[r]] -4
  age <-x$age[[r]]
  d<-data.frame(val_user,pos,age)
  print(d)
}
df<-rbind(df,d)
View(df)

   in df only have the last result, the ideia is have the new results
calculated in the for loop

thanks

--
View this message in context: http://r.789695.n4.nabble.com/Copy-dataframe-for-another-tp4456893p4459068.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list