Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop_na = FALSE not working when shape = "flat"? #294

Closed
ethanwhite opened this issue Sep 14, 2023 · 2 comments · Fixed by #305
Closed

drop_na = FALSE not working when shape = "flat"? #294

ethanwhite opened this issue Sep 14, 2023 · 2 comments · Fixed by #305
Assignees

Comments

@ethanwhite
Copy link
Member

rodents_crosstab = as_tibble(summarize_rodent_data(
  clean = TRUE,
  type = "Rodents",
  shape = "crosstab",
  time = "newmoon",
  output = "abundance",
  na_drop = FALSE,
  zero_drop = FALSE
))

rodents_flat = as_tibble(summarize_rodent_data(
  clean = TRUE,
  type = "Rodents",
  shape = "flat",
  time = "newmoon",
  output = "abundance",
  na_drop = FALSE,
  zero_drop = FALSE
))

rodents_crosstab |>
  select(newmoonnumber, PP) |>
  filter(newmoonnumber > 403) |>
  print(n = 20)
# A tibble: 163 × 2
   newmoonnumber    PP
           <int> <int>
 1           404     2
 2           405     7
 3           406    22
 4           407    22
 5           408    NA
 6           409    39
 7           410    NA
 8           411   104
 9           412    NA
10           413    36
# ℹ 153 more rows
# ℹ Use `print(n = ...)` to see more rows
rodents_flat |>
  filter(species == "PP") |>
  filter(newmoonnumber > 403) |>
  select(newmoonnumber, abundance) |>
  print(n = 20)
# A tibble: 122 × 2
   newmoonnumber abundance
           <int>     <int>
 1           404         2
 2           405         7
 3           406        22
 4           407        22
 5           409        39
 6           411       104
 7           413        36
 8           415         2
 9           416         0
10           417        12
# ℹ 112 more rows
# ℹ Use `print(n = ...)` to see more rows
@ethanwhite
Copy link
Member Author

Fix portalr NA bug

@gmyenni
Copy link
Collaborator

gmyenni commented Sep 19, 2024

This is actually an issue with na_drop = FALSE not working to the species level when time ≠ "period" because grid expansion happens before user-defined time gets added.
Solution is to add a tidyr::complete step in the add_time function so any table gets expanded for any time index to the species and potentially plot level (but not lower, eg not stake or day).

gmyenni added a commit that referenced this issue Sep 19, 2024
Force species-level filling of missing newmoons when na_drop = FALSE, closes #294
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants