Skip to content
Snippets Groups Projects
Select Git revision
  • 70cb65b9373178d7a501e3033b4e8861430b0025
  • master default
2 results

testFill.R

Blame
  • 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))