I occasionally find that it would be useful to get the printed representation of an R object as a character string, like Python's repr
function or Lisp's prin1-to-string
. Does such a function exist in R? I don't need it to work on complicated or weird objects, just simple vectors and lists.
Edit: I want the string that I would have to type into the console to generate an identical object, not the output of print(object)
.
dput
? – Eckart> x <- 1:10
> x
– Aerophagiarepr
does in Python (for supported objects). – Moonshiner