Skip to content

Instantly share code, notes, and snippets.

@monogenea
Created October 7, 2019 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monogenea/bee008b27e33e4bea6dda5ee9ffbeedf to your computer and use it in GitHub Desktop.
Save monogenea/bee008b27e33e4bea6dda5ee9ffbeedf to your computer and use it in GitHub Desktop.
(allTabs <- excel_sheets("data.xlsx")) # list tabs
# Read female reproductive output
fro <- read_xlsx("data.xlsx", sheet = allTabs[2])
# Assess missingness
sum(complete.cases(fro)) / nrow(fro)
# only 0.57 complete records; which vars have at least one NA?
names(which(apply(fro, 2, function(x){any(is.na(x))})))
# Filter out missingness in fledged eggs, the model does not cope with it
fro %<>% slice(which(!is.na(Eggs_fledged))) %>%
as.data.frame()
fro %<>% mutate(female_id = as.integer(factor(Female_ID_coded)),
year_id = as.integer(factor(Year)),
group_id = as.integer(factor(Group_ID_coded)),
Min_age_Z = scale(Min_age),
Group_size_Z = scale(Group_size),
Mean_eggsize_Z = scale(Mean_eggsize))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment