[R] Using the get() function on an object within a list

klc kcurti at hotmail.com
Tue Mar 30 23:23:58 CEST 2010


I am trying use the get function to return the value of an object within a
list.  As an abbreviated example:

"original" represents a list of several objects, one of which is "a.1".
   names(original) <- c("a.1","a.2","a.3","b.1","b.2")
   original$a.1 <- c(4,3)

When I enter:
R returns the following vector
  [1] 4 3
however, when I enter:
R returns the following error: 
  "Error in get("original$a.1") : object 'original$a.1' not found"

Does anyone happen to know how to resolve this error?

I pose this question because ultimately I would like to use the get function
to convert particular objects within "original" into separate lists as:
   species <- c(1,2,3)
   A <- vector('list',length(species))
   A <- lapply(paste("original$a.", species, sep=""), get)

I apologize if I missed this question in a previous post.

Many thanks-
View this message in context: http://n4.nabble.com/Using-the-get-function-on-an-object-within-a-list-tp1745965p1745965.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list