0

I am quite new with R and this is my first post on this forum.

I have a data frame based on the vlaues from a CSV file in to a dataframe and it looks like:

ID name   V1   V2    V3    V4    V5
7  ABC    5    NA    NA    NA    NA
7  ABC    NA   3     NA    NA    NA
7  ABC    NA   NA    6     NA    NA
7  ABC    NA   NA    NA    3     NA
7  ABC    NA   NA    NA    NA    NA

This is the output which i am trying to get out from this dataframe:

ID name   V1   V2    V3    V4    V5
7  ABC    5    3     6     3     NA
  • it's not the same question. The answer can be incorrect for this one – jyjek Jun 13 '18 at 08:45
  • @jyjek The first answer from the duplicated link works for me. `df %>% group_by(ID, name) %>% summarise_each(funs(sum(., na.rm=TRUE)))` If this is different question OP needs to clarify it and I would be happy to reopen it. – Ronak Shah Jun 13 '18 at 08:48
  • @RonakShah Hi. I think `sum`!=last value in this case. Anyway question isn't fully correct – jyjek Jun 13 '18 at 08:53
  • Maybe this help `df%>%group_by(ID)%>%tidyr::fill_(names(.))%>%dplyr::slice(nrow(.))` – jyjek Jun 13 '18 at 08:54

0 Answers0