Hi,
I've spent a full day trying to use fill from tidyr to fill missing values by group, like so:
vars_to_fill <- c(3:4,7:8)
df <- df %>% dplyr::arrange(ID, time) %>% dplyr::group_by(ID) %>%
tidyr::fill(vars_to_fill)
And I cannot, for the life of me, get it to work with my dataset.
It works with small throwaway datasets that I create, but if I use my dataset or any subset of it, it no longer works.
I apologize for the inconvenience, but I am unable to provide the dataset in question due to confidentiality agreements.
If it helps, the packages that I had loaded were:
library(foreign)
library(Hmisc)
library(RODBC)
library(dplyr)
library(tidyr)
library(reshape)
library(magrittr)
I also had
library(plyr) loaded but I unloaded and restarted the session and still, no luck.