I\'m trying to paste strings from a reshaped dataset. I\'m using the data.table package as follows:
m<-data.frame(x=rep(c(\"a\",\"b\"),20),y=factor(sample
For completeness' sake, an official answer:
If you use paste(y,collapse=",")
instead, it should work.
The toString(y)
function produced the same result as paste(y, collapse = ", ")
, I use it as substitute for the longer paste version. So
DT[, toString(y), by = x]
would yield the outcome
# x V1
#1: a v, o, q, p, t, c, y, d, n, r, o, k, v, r, t, n, e, f, g, u
#2: b y, j, t, l, w, r, s, w, b, x, h, j, o, k, a, c, r, c, b, e
which is the same for paste
DT[, paste(y, collapse = ", "), by = x]