[R] Copy dataframe for another
David Winsemius
dwinsemius at comcast.net
Fri Mar 9 16:41:15 CET 2012
On Mar 9, 2012, at 5:31 AM, RMSOPS wrote:
> 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))
x <- data.frame(name=paste("x", 1:6, sep=""),
pos=3+1:6
age=c(20,20, 21,24,27,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)
>
It is generally better to spend more time describing the problem.
Attempting to read the mind of new R users who come from other
programming paradigms is often unrewarding.
--
David.
> 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.
PLEASE: Include context. We are NOT reading this on Nabble.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list