Turning a language object into a String in R
r, string
Solution
Use `deparse`:
x <- call("sum",1:10)
as.character(x)
[1] "sum" "1:10"
deparse(x)
[1] "sum(1:10)"
Problem
I am writing some code in R to handle errors/warnings. The condition object i get back is a list of a message as string and a call object, representing the function call, that caused the error. I want to have a string that is the same as if i simply used print() on the call object. However using as.character() or paste() gives back a vector of multiple strings representing the function name and parameters. Is there an easy way to do this or do i have to build the string myself?