I have a dataframe as follows:
df <- structure(list(a = c("1", "2", "3"), b = c("Tom", "Jen", "Rob"
), c = c("Wrist", "Ankle", "Neck")), class = "data.frame", row.names = c(NA,
-3L))
I'm trying to collapse my columns into a single column where each row contains a single text string comprised of data from each column separated by a delimiter (specifically a ; [colon]).
My current code converts my data into a text string but instead of multiple rows it's a single cell containing all data in the data frame:
data.frame(format_delim(df[1:nrow(df),],";", append = FALSE, col_names = FALSE, quote_escape = FALSE))
What should I do instead to obtain the following data frame?
structure(list(c..1.Tom.Wrist....2.Jen.Ankle....3.Rob.Neck.. = c("1;Tom;Wrist",
"2;Jen;Ankle", "3;Rob;Neck")), class = "data.frame", row.names = c(NA,
-3L))
Thanks. Hope this was easy to follow.