Skip to content

Instantly share code, notes, and snippets.

@kylebutts
Last active October 30, 2020 14:12
Show Gist options
  • Save kylebutts/f4aee0efc1ae232c50bfcc77d36ba462 to your computer and use it in GitHub Desktop.
Save kylebutts/f4aee0efc1ae232c50bfcc77d36ba462 to your computer and use it in GitHub Desktop.
Make Spreadsheet to check for missing obs. in panels. Row is id, column is year, element = 1 if present.
# Calling the panel identifiers as id, year
df %>%
mutate(present = 1) %>%
complete(nesting(id), year) %>%
mutate(present = replace_na(present, 0)) %>%
select(id, year, present) %>%
pivot_wider(names_from = year, values_from = present)
@kylebutts
Copy link
Author

Need to change id and df and this will produce something like this:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment