A data set(dat),has 2 variables: x and a, and 100 rows.
 
I wanna add 2 variables,and call the new data set dat1:
var1:f = a/median(a)
var2:x_new = x*f
 
My solution:
dat1<-transform(dat,f = a/median(a),x_new = x*f)
But gets error reply which says that "f" is not exits since dat has no 
variables called "f".
 
So I have to do through 2 steps:
dat0<-transform(dat,f=a/median(a))
dat1<-transform(dat0,x_new=x*f)
 
How to do it through 1 step?
 
Many thanks!
 
 
        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to