I was wondering how to paste() g and h to obtain my desired combination shown below?
g <- c("compare","control")
h <- "Correlation"
paste0(h, g, collapse = "()") # Tried this with no success
desired <- "Correlation (compare,control)"
>Solution :
Try this,
paste0(h, ' (', toString(g), ')')
#[1] "Correlation (compare, control)"
If you don’t want the space in the comma then we can do it manually with paste(), i.e.
paste0(h, ' (', paste(g, collapse = ','), ')')
#[1] "Correlation (compare,control)"