I have data as follow.
1 b c 10
1 b c 30
2 c a 20
then I want to transform the data as below.
1 b c 10,30
2 c a 20
How to achieve my goal using R?
We can use dplyr
library(dplyr)
df1 %>%
group_by_(.dots = names(df1)[1:3]) %>%
summarise(col4 = toString(col4))
# col1 col2 col3 col4
# <int> <chr> <chr> <chr>
#1 1 b c 10, 30
#2 2 c a 20