[R] transform R function
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Wed Mar 7 19:31:54 CET 2007
lamack lamack wrote:
> Dear all, Why the transform function does not accept two statistics
> functions?
>
> a = data.frame(matrix(rnorm(20),ncol=2))
>
> transform(a,M.1=mean(X1),M.2=mean(X2)) # does not works
>
> #while:
>
> transform(a,M.1=mean(X1),M2=log(abs(X2))) #works
>
>
It's a variation of this effect:
data.frame(airquality, list(x=1)) #works
data.frame(airquality, list(x=1, y=2)) #works not
Not quite sure what the logic of that is....
Of course transform() isn't really intended to handle anything but
transformed vectors of the same length as the original.
More information about the R-help
mailing list