Hello, I read the help as well as the examples, but I can not figure out why the following code does not produce the *given* row names, "x" and "y": x <- 1:20 y <- 21:40 rbind( x=cbind(N=length(x), M=mean(x), SD=sd(x)), y=cbind(N=length(y), M=mean(y), SD=sd(y)) ) Could you please help? Thank you S?ren
This gives what you want: rbind.data.frame( x=cbind(N=length(x), M=mean(x), SD=sd(x)), y=cbind(N=length(y), M=mean(y), SD=sd(y)) ) On Fri, Jan 29, 2010 at 8:49 AM, <soeren.vogel at eawag.ch> wrote:> Hello, > > I read the help as well as the examples, but I can not figure out why the > following code does not produce the *given* row names, "x" and "y": > > x <- 1:20 > y <- 21:40 > rbind( > ?x=cbind(N=length(x), M=mean(x), SD=sd(x)), > ?y=cbind(N=length(y), M=mean(y), SD=sd(y)) > ) > > Could you please help? > > Thank you > > S?ren > > ______________________________________________ > R-help at 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
Hi! 29.01.2010 12:49, soeren.vogel at eawag.ch wrote:> Hello, > > I read the help as well as the examples, but I can not figure out why > the following code does not produce the *given* row names, "x" and "y": > > x <- 1:20 > y <- 21:40 > rbind( > x=cbind(N=length(x), M=mean(x), SD=sd(x)), > y=cbind(N=length(y), M=mean(y), SD=sd(y)) > ) >Maybe because the cbinds in your code produce matrices: is.matrix(cbind("N"=length(x), "M"=mean(x), "SD"=sd(x))) [1] TRUE Quote ?rbind: "For cbind (rbind) the column (row) names are taken from the colnames (rownames) of the arguments if these are matrix-like." HTH, Kimmo