[R] transform R function

2007-03-07 Thread lamack lamack
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

Best regards

JL

_
O Windows Live Spaces é seu espaço na internet com fotos (500 por mês), blog 
e agora com rede social http://spaces.live.com/

__
R-help@stat.math.ethz.ch 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.


Re: [R] transform R function

2007-03-07 Thread Peter Dalgaard
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.

__
R-help@stat.math.ethz.ch 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.