Re: [R] get names of list elements

2009-10-31 Thread Gabor Grothendieck
list() does not assign names but data.frame(a, b) does and can be used at least in the case shown where a and b have the same length. And, of course, a data frame is a list. > a <- 1:5; b <- 6:10 > names(data.frame(a, b)) [1] "a" "b" 2009/10/31 Chirok Han : > Hi > > Consider >> a <- 1:5; b <- 6

Re: [R] get names of list elements

2009-10-31 Thread Ista Zahn
I don't think so. You can only get the name of something that has a name, and in this case it does not. -Ista 2009/10/31 Chirok Han : > Hi > > Consider >> a <- 1:5; b <- 6:10 >> x <- list(a=a,b=b) >> y <- list(a,b) > > I can get c("a","b") from x using names(x). Is it also possible to get > "a" a

[R] get names of list elements

2009-10-31 Thread Chirok Han
Hi Consider > a <- 1:5; b <- 6:10 > x <- list(a=a,b=b) > y <- list(a,b) I can get c("a","b") from x using names(x). Is it also possible to get "a" and "b" from y? (The command "names(y)" gives NULL.) Thanks in advance. Chirok __ R-help@r-project.org