I am setting up a new dataset from grouped data but I am unable to ungroup the data as the code runs and gives the same variables without any changes in the dataframe.
this is the data set I have
s.no Mno drug3
1 100173 9, 3, NA, NA
2 100463 18, 18, 1, NA, NA, NA
3 10061 18, 9, 2, 3, NA
4 101793 0
5 101876 0
6 101909 0
7 102685 0
8 102707 0
9 103171 18, 2, 1, NA, NA
A <- B %>%
group_by(Mno) %>%
summarise(drugs = paste(drug3, collapse=", ")) %>%
ungroup(drug3)
I need the output like this
s.no Mno drug3
1 100173 9
2 100173 3
3 100173 NA
4 100173 NA
5 100463 18
6 100463 18
7 100463 1
8 100463 NA
9 100463 NA
10 100463 NA
11 10061 18
12 10061 9
13 10061 2
14 10061 3
15 10061 NA
16 101793 0