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.
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.