[R] documentation / An Intro to R / list manipulation
Robbie Morrison
robbie at actrix.co.nz
Thu Jun 4 19:02:23 CEST 2009
Hello R users
http://cran.r-project.org/doc/manuals/R-intro.html
An Introduction to R
6.2 Constructing and modifying lists
After a short but successful struggle with nested
associative arrays (using named lists), I think the
following documentation change might be beneficial.
The existing description and example (see below)
implies that the given statement would transfer the
component name as well (not so):
> Lst[5] <- list(matrix=Mat)
---------------------------------
new text for section 6.2
---------------------------------
Lists, like any subscripted object, can be extended by
specifying additional components. For example
> Lst[5] <- list(Mat)
This new component can also be named, using either a
character string (as shown) or suitable string variable
> names(Lst)[5] <- "matrix"
---------------------------------
test code
---------------------------------
Mat <- matrix()
Lst <- list()
Lst[1] <- list(matrix = Mat)
str(Lst)
# List of 1
# $ : logi [1, 1] NA
names(Lst)[1] <- "matrix"
str(Lst)
# List of 1
# $ matrix: logi [1, 1] NA
many thanks to the R team in general
Robbie
ps: I'm using R for visualizing data, including
directed graphs (via adjacency lists) and timeseries,
and for summarizing relatively diverse but consistent
datasets
---
Robbie Morrison
PhD student -- policy-oriented energy system simulation
Technical University of Berlin (TU-Berlin), Germany
University email (redirected) : morrison at iet.tu-berlin.de
Webmail (preferred) : robbie at actrix.co.nz
[from IMAP client]
More information about the R-help
mailing list