Select Git revision
-
Ben Anderson authoredBen Anderson authored
testFill.R 596 B
# testing methods to fill in NA
require(tidyverse)
require(readxl)
require(here)
testF <- paste0(here::here(), "/data/fakeTimeUseActsFile.xlsx")
testDF <- readxl::read_xlsx(testF)
head(testDF)
with(testDF, table(code, text))
# https://stackoverflow.com/questions/40040834/replace-na-with-previous-or-next-value-by-group-using-dplyr
testFilledDF <- testDF %>%
group_by(userID) %>%
fill(code, text) %>% # first go downwards
fill(code, text, .direction = "up") # then back up to fix the ones that are left (any NA at and just after the start)
with(testFilledDF, table(code, text))