[R] How can I get "A$Title"?
    C. Joseph Lu 
    cjlu at ibm.stat.ncku.edu.tw
       
    Mon Dec 18 10:05:31 CET 2000
    
    
  
Thanks Prof. Ripley and Dr. Venables for your prompt responses!
It seems like the key to my question is to use
    function(x) get(x)$Title
via sapply, as suggested by Prof. Ripley:
> sapply(as.list(LETTERS), function(x) get(x[1])$Title)
(I found sapply(LETTERS, function(x) get(x)$Title) works the same.)
or via lapply, as suggested by Dr. Venables:
> titles <- lapply(LETTERS, function(x) get(x)$Title)
As in terms of print them out,
> sapply(LETTERS, function(x) get(x)$Title
is good enough, or use Dr. Vernables' suggestion:
> print(paste(unlist(titles), collapse = "\n"), quote = FALSE)
however, collapse = "\n" should be sep = "\n" instead.
Thanks very much again!
Look forward the R- 1.2.0 for Windows 98!
> > -----Original Message-----
> > From: C. Joseph Lu [mailto:cjlu at ibm.stat.ncku.edu.tw]
> > Sent: Monday, 18 December 2000 17:47
> > To: 'r-help'
> > Subject: [R] How can I get "A$Title"?
> >
> >
> > 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
> >
> > Is there a way to create a vector of A$Title, B$Title, ... without
> > double quotes?
> >
> > My version is
> > > version
> >          _
> > platform Windows
> > arch     x86
> > os       Win32
> > system   x86, Win32
> > status
> > major    1
> > minor    1.1
> > year     2000
> > month    August
> > day      15
> > language R
Best regards,
C. Joseph Lu
Department of Statistics
National Cheng-Kung University
Tainan, Taiwan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
    
    
More information about the R-help
mailing list