I have a data frame such as
df1 <- data.frame(
A = c("USA","USA","UK","UK","France"),
B = c("Boston","New York","Cambridge","Oxford","Paris")
)
And I would like to end up with a new data frame:
df2 <- data.frame(
A = c("USA","UK","France"),
B = c("Boston; New York","Cambridge; Oxford","Paris")
)
How do I aggregate by A using paste()
as the "summarizing" function, or something equivalent to this? Thanks in advance for any help provided.