I was just surprised by very un-intuitive behaviour of paste(), which appears 
to collapse a one-column data frame or one-element list into a deparsed 
expression, rather than producing the expected string. Can someone kindly 
explain what's going on here?


reprex:
=======

list(s = c("xyz", "uvw"))
#     s
# 1 xyz
# 2 uvw

paste(list(s = c("xyz", "uvw")), collapse = "")
# [1] "c(\"xyz\", \"uvw\")"   # This is unexpected!

I would have expected:
# [1] "xyzuvw"
 
... which I do get with e.g.
paste(list(s = c("xyz", "uvw"))$s, collapse = "")

But what logic is there in returning a deparsed expression?



Thanks!
Boris
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to