Skip to content
Prev 215635 / 398500 Next

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

On Mar 30, 2010, at 5:23 PM, klc wrote:

            
> get("original")$a.1
[1] 4 3

The get function will not parse and evaluate complex expressions for  
you. And the "$" operator is probably not as useful for this  
application as "[[" would be. See below
> sapply(names(original), function(x) original[[x]])
$a.1
[1] 4 3

$a.2
NULL

$a.3
NULL

$b.1
NULL

$b.2
NULL

 > sapply(1:3, function(x) original[[x]])
[[1]]
[1] 4 3

[[2]]
NULL

[[3]]
NULL
David Winsemius, MD
West Hartford, CT