Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df[3:13] <- sapply(df[3:13], as.numeric)
- df$YearMonth <- strftime(df$date, "%Y %m")
- #Get last available date in a month
- LastDate <- function(x){
- y <- filter(x, !is.na(x))
- last(y)
- }
- LastDate(df[1:20,1])
- df %>%
- select(China:US, YearMonth) %>%
- group_by(YearMonth) %>%
- summarise_all("LastDate")
- x <- 1:10
- LastDate(x)
- x[10] = NA
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement