ripley@stats.ox.ac.uk
2000-Dec-29 09:44 UTC
[Rd] unlisting a list with names components (PR#645)
Summary of report from Peter Perkins <pperkins@ucsd.edu> on Sat Aug 26 09:41:52 2000 i think the lines below demonstrate a problem with unlist when the list contains components that are names. _anything_ can go in a list, right? this came up in the context of trying to unlist(list(attr(terms(formula), "variables")).> list2 <- list(a="a", b=as.name("b")) > unlist(list2)$a [1] "a" $b b This seems to be intentional, but the documentation is wrong. The C code says /* If a non-vector argument was encountered (perhaps a list if */ /* recursive = F) then we must return a list. Otherwise, we use */ /* the natural coercion for vector types. */ A language element (e.g. a `name') is non-vector. So anything can go in a list, but unlist cannot sort out anything. S does this differently, but then it stores non-vector types differently. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Maybe Matching Threads
- unlisting a list with names components (PR#645)
- Re: I want to pull out an element from each of a list of matrices
- Re: (PR#1210) an error message from scan() surprised vograno@arbitrade.com.
- installation problems on Windows (was Problems with some components of R)
- Shared components?