Hi Godmar Back <god...@gmail.com> napsal dne 09.07.2009 14:09:42:
> On Thu, Jul 9, 2009 at 4:50 AM, Petr PIKAL <petr.pi...@precheza.cz> wrote: > Hi > > r-help-boun...@r-project.org napsal dne 09.07.2009 02:57:33: > <snip> > Not so weird. What do you expect from > > c(1:5, 10:20, 30:50) > > You mean what I expect personally, with my background? > I'd expect a jagged array of arrays. > > 1 2 3 4 5 > 10 11 12 .. 20 > 30 31 .. 50 > > If operator c() constructs an array out of its arguments, and if the sequence > operator : constructs an array, then c(1:5) should construct an array of arrays. > is.array(1:5) [1] FALSE > is.vector(1:5) [1] TRUE > Why. Not much is said about arrays in man page for c. The operator concatenates its arguments. If they are vectors the output is again a vector. If they are lists the output is list. try c(1:5,10:20) c(1:5, list(10:20) c(1:5, data.frame(10:20) and regarding arrays, matrices and vectors - AFAIK arrays and matrices are just vectors with dim attribute, which is stripped by c c is sometimes used for its side effect of removing attributes except names, for example to turn an array into a vector. as.vector is a more intuitive way to do this, but also drops names. Note too that methods other than the default are not required to do this (and they will almost certainly preserve a class attribute). > > That is basically what your function do. With slight modification you can > get tabular output without mapply > > multipleoutput <- function (x) { > result.s <- x^2 > result.c <- x^3 > result.e <- exp(x) > cbind(square=result.s, cube=result.c, exp=result.e) > } > > Just for clarification: is there any significance to your using the . in the > names result.s, result.c, etc. like there would be in some other languages > where dot is an operator? No. AFAIK one dot does not have any special meaning unless you use it in the beginning of name. In that case the variable is not listed by ls() function. See ?ls and argument all.names Regards Petr > > - Godmar ______________________________________________ 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.