Skip to content
Prev 309790 / 398502 Next

Can you turn a string into a (working) symbol?

HI,

get("DD[2]")
#[1] 5
If you wanted to change the one without quotes:


?new1<-function(x,y) {eval.parent(substitute(x<-y))}
?new1(DD[2],7)
?DD[2]
#[1] 7
DD
#[1] 1 7 3
A.K.



----- Original Message -----
From: andrewH <ahoerner at rprogress.org>
To: r-help at r-project.org
Cc: 
Sent: Saturday, November 3, 2012 11:10 PM
Subject: Re: [R] Can you turn a string into a (working) symbol?

Yes, the assign command goes a little way toward what what I was hoping for. 
But it requires a different syntax, and it does not in general let you use
quoted expressions that you could? use with other assignment operators. For
instance,
[1] 1 2 3

So I am still looking for a function that produces an output that is fully
equivalent to the string without quotation marks.? Or for a definite
statement that no such function can exist.

Thanks so much for your attention to this problem.
andrewH




--
View this message in context: http://r.789695.n4.nabble.com/Can-you-turn-a-string-into-a-working-symbol-tp4648343p4648366.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.