[R] Help needed with eval parse
Huzefa Khalil
huze|@@kh@||| @end|ng |rom um|ch@edu
Wed Sep 18 14:43:23 CEST 2019
Hello R-users,
I have been running a script which produces objects based on the
column names of a data.frame. The column names are of the form CB_1-1,
CB_1-2, etc. Now this calculation was rather long and memory
intensive, so I would rather not have to do it again after fixing the
column names using "make.names". As a consequence, I am left with a
bunch of R objects with `-` in the name.
Accessing them is proving challenging and any help would be appreciated.
Reproducible example:
`cb_1-2` <- "hello world"
t <- "cb_1-2"
t <- as.name(t)
t <- eval(parse(text = t))
Error in eval(parse(text = t)) : object 'cb_1' not found
Thanks.
huzefa
More information about the R-help
mailing list