You can use get to grab the object, then subset it:
> test <- list(a=2)
> get('test')[['a']]
[1] 2
This way you can even have the variable names in other variables:
> whichvar <- 'a'
> whichlist <- 'test'
> get(whichlist)[[whichvar]]
[1] 2
Even better would be to have any lists that you want to
On 12/03/2014 07:42, Alaios wrote:
Hi all,
I would like to turn some long strings like MyString$Myfield$MySubfield into
variables but it looks like that the get does not like lists
Those are expressions not names, so you need to parse them.
> eval(parse(text = "test$a"))
[1] 2
so for exam
Hi all,
I would like to turn some long strings like MyString$Myfield$MySubfield into
variables but it looks like that the get does not like lists
so for example:
test<-list(a=2)
test
>$a
[1] 2
get("test")
>$a
[1] 2
get("test$a")
>Fehler in get("test$a") : Objekt 'test$a' nicht ge
3 matches
Mail list logo