[R] [External] Convert a character string to variable names
Erin Hodgess
er|nm@hodge@@ @end|ng |rom gm@||@com
Tue Feb 8 00:08:08 CET 2022
Awesome, thank you so much!
Sincerely,
Erin
Erin Hodgess, PhD
mailto: erinm.hodgess using gmail.com
On Mon, Feb 7, 2022 at 4:05 PM Richard M. Heiberger <rmh using temple.edu> wrote:
> > x <- c("mtcars$disp", "mtcars$hp", "mtcars$cyl")
> > x
> [1] "mtcars$disp" "mtcars$hp" "mtcars$cyl"
> > eval(parse(text=x))
> [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4
> > for (i in x) print(eval(parse(text=i)))
> [1] 160.0 160.0 108.0 258.0 360.0 225.0 360.0 146.7 140.8 167.6 167.6
> 275.8 275.8 275.8 472.0 460.0 440.0 78.7 75.7 71.1 120.1 318.0
> [23] 304.0 350.0 400.0 79.0 120.3 95.1 351.0 145.0 301.0 121.0
> [1] 110 110 93 110 175 105 245 62 95 123 123 180 180 180 205 215 230
> 66 52 65 97 150 150 245 175 66 91 113 264 175 335 109
> [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4
>
>
> > On Feb 07, 2022, at 17:55, Erin Hodgess <erinm.hodgess using gmail.com> wrote:
> >
> >> .x
> >
> > [1] "mtcars$disp" "mtcars$hp" "mtcars$cyl"
>
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list