0

I am trying to collapse the column b so that entries in column a will have only one row and column B will be multiple values separated by ; my code is:(my file is known as disease)

a       b
2012    cancer
2013    HIV
2014    cancer
2014    HIV

library(dplyr)
summary <- disease %>% 
   group_by(a) %>%
   summarise(b = paste0(b, collapse = ';')) %>% 
   ungroup()

This does not give me any error but does not yield the desired results too. Summary file is generated but has only one column named b and that is empty.

shiny
  • 2,920
  • 8
  • 28
  • 69

0 Answers0