On Mon, 18 Dec 2000, C. Joseph Lu wrote:
> Dear R-friends,
>
> I have whole bunch of objects, say, A, B, ..., Z,
> all of them are "list" and haveing "Title" (a character
string)
> as their first element.
> E.g.,
> > A$Title
> [1] "Airplane Component"
>
> What I like to do is to find a way to printout all the Titles at one
> time.
> I tried the following:
> > paste(LETTERS, "Title", sep="$") -> tmp
> but can't find a way to continue since
> > get(tmp[1])
> Error in get(x, envir, mode, inherits) : variable "A$Title" was
not
> found
Right: the variable is named A, not A$Title.
> Is there a way to create a vector of A$Title, B$Title, ... without
> double quotes?
Do you want the names or the values? For the latter
sapply(as.list(LETTERS), function(x) get(x[1])$Title)
The quotes are part of the printing of the titles, not the titles
themselves: use cat() or print(quote=FALSE) to suppress them.
--
Brian D. Ripley, ripley at 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-help 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-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._