Reputation: 1156
How to clean the above data in R dataframe to
Upvotes: 0
Views: 209
Reputation: 15123
You may try using dplyr
,
dummy <- data.frame(
tic = c("FCCY", "FCCY"),
conm = c("FiveC", "FiveC"),
Records = c(1,1),
Fourcent = c(7,NA),
Fivecent = c(NA,9)
)
tic conm Records Fourcent Fivecent
1 FCCY FiveC 1 7 NA
2 FCCY FiveC 1 NA 9
library(dplyr)
dummy %>%
group_by(tic, conm) %>%
summarise(across(everything(), ~unique(na.omit(.x))))
tic conm Records Fourcent Fivecent
<chr> <chr> <dbl> <dbl> <dbl>
1 FCCY FiveC 1 7 9
Upvotes: 1