[R] How to "call" an object given a string?

arun smartpink111 at yahoo.com
Mon Apr 29 14:47:17 CEST 2013


Hi, res<- unlist(mget(ls()))
names(res)<-NULL
 res
#[1]  5  5 10
A.K.



----- Original Message -----
From: Rui Esteves <ruimaximo at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Monday, April 29, 2013 7:07 AM
Subject: [R] How to "call" an object given a string?

Hello,

This is very basic and very frustrating.

Suppose this:
>A=5
>B=5
>C=10

> ls()
"A"
"B"
"C"

I would like this
>xpto()
5
5
10

How can I do xpto()?

Thanks
Rui

    [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list