I want to paste elements of a vector together, e.g
vec <- c("a","b","c")
to string <- "a,b,c"
I tried paste0(vec, sep =",", collapse= "")
but the output is string <- "a,b,c,"
What is the correct way to do this?
I want to paste elements of a vector together, e.g
vec <- c("a","b","c")
to string <- "a,b,c"
I tried paste0(vec, sep =",", collapse= "")
but the output is string <- "a,b,c,"
What is the correct way to do this?
Use it like this:
paste0(vec, collapse=",")
the "collapse" argument specifies the value to use when collapsing the values into a single string