k-zar k-zar - 1 year ago 82
R Question

R function to convert object into code

I am looking for a function in R that converts an object into code that can be used to create a replica of that object. Something like this:

> myObject=c(1, 2, 3)
> magicFunction(myObject)
[1] "c(1,2,3)"

I think this function exists, but I cannot find it. Would greatly appreciate your help.

Answer Source

We can use deparse

#[1] "c(1, 2, 3)"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download