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?
Use deparse
:
x <- call("sum",1:10)
as.character(x)
[1] "sum" "1:10"
deparse(x)
[1] "sum(1:10)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With