Skip to content
Snippets Groups Projects
Commit 70cb65b9 authored by Ben Anderson's avatar Ben Anderson
Browse files

testng methods to fill in NA

parent 0184e262
Branches
No related tags found
No related merge requests found
# 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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment