transform output similar to a table to a string

You can use paste :

tmp <- table(df$x)
paste(names(tmp), tmp, sep = ':')
#[1] "a:2" "b:1"

Or as one string :

paste(names(tmp), tmp, sep = ':', collapse = ' ')
[1] "a:2 b:1"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top