Hi,
I am querying a database in SQL Server using dbplyr (this package is amazing) and I would like to concatenate the strings of the column name, grouping by id and removing the duplicated names. For example:
| id |
name |
| 1 |
paul |
| 1 |
paul |
| 1 |
john |
| 2 |
lea |
| 2 |
peter |
to
| id |
names |
| 1 |
paul, john |
| 2 |
lea, peter |
I tried to use the code below with the collapse argument, but it says it is not possible.
dt <- dt %>%
dplyr::select(id, name) %>%
dplyr::distinct() %>%
dplyr::group_by(id) %>%
dplyr::mutate(names = paste(name, collapse = ", ")) %>%
dplyr::collect()
Error: collapse not supported in DB translation of paste().
Is there any way I can do this using dbplyr?
Thank you.
Hi,
I am querying a database in SQL Server using dbplyr (this package is amazing) and I would like to concatenate the strings of the column name, grouping by id and removing the duplicated names. For example:
to
I tried to use the code below with the collapse argument, but it says it is not possible.
Is there any way I can do this using dbplyr?
Thank you.