Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the opposite of dput() in R?

Tags:

r

eval

I have a function which for some reason returns a a set of characters in the same way dput() does, i.e as "c("A","B","C")". How do get it back to a character vector. i.e [1] "A" "B" "C"

See the following toy example

x = c("A", "B", "C")
dpx = dput(x)

How do I get dpx back to x again?

like image 830
Christiaan Avatar asked Oct 24 '25 06:10

Christiaan


1 Answers

You can do this:

eval(parse(text = "c(\"A\",\"B\",\"C\")"))

but it is probably a better idea to fix the output of that function.

like image 130
Paul Hiemstra Avatar answered Oct 26 '25 20:10

Paul Hiemstra