[R] Escape sequence in eval ()

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Jun 16 15:42:13 CEST 2011



On 15.06.2011 15:58, Franc Lucas wrote:
>
>     Hello,
>     I am wondering how to get the quotation marks into a variable expression. I
>     can't escape it with the backslash \ ...
>     Example:
>     I can access my data frame via
>     TABLE$"2011-01-02"$columnD
>     Now I want to do this automatically.. (with a for loop)..

Use the form

TABLE[["2011-01-02"]][["columnD"]]

and you can easily replace:

>     a<- TABLE
>     b<- " \"2011-01-02\" "

use simply

b <- "2011-01-02"


>     c<- "columnD"

Now forget the nonsense below and just do:
TABLE[[b]][[c]]

Uwe Ligges


>     acessmytable<- paste(a,b,c, sep="$")
>     parse(text="accessmytable")
>     eval(accessmytable)
>     It will return
>     [1] "TABLE$\"2011-01-02\"$close"
>     but I need
>     TABLE$"2011-01-02"$close
>     I highly appreciate your help!
>     Sincerely,
>     Franc
>     BS Student, University of Mannheim
>
>     Schon gehört? WEB.DE hat einen genialen Phishing-Filter in die
>     Toolbar eingebaut! [1]http://produkte.web.de/go/toolbar
>
> References
>
>     1. http://produkte.web.de/go/toolbar
> ______________________________________________
> 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