bbsAssistant icon indicating copy to clipboard operation
bbsAssistant copied to clipboard

QualityControlID not filtered correctly

Open see24 opened this issue 2 years ago • 0 comments

When QualityControlID = 1 in munge_bbs_data, which is the default, I am still getting results with 0 in the QualityControlID column.

I checked the code and the issue is that the argument and column have the same name and inside the dplyr filter function it looks first in the context of the data frame so it does not use the value of QualityControlID = 1 that was supplied as an argument but rather the column in the data frame.

I will attempt to make a pull request now since it is an easy fix!

library(bbsAssistant)
library(dplyr)

# Set parameters for script
start_yr <- 1991
end_yr <- 2023


# Get the BBS data
# downloads the data the first time and will import it if already downloaded.
bbs_raw <- grab_bbs_data()

obs_ON_1991 <- munge_bbs_data(
  bbs_raw,
  states = region_codes %>% filter(State == "ontario") %>% pull(StateNum),
  zero.fill = FALSE,
  year.range = start_yr:end_yr,
  keep.stop.level.data = TRUE
)

see24 avatar Jul 04 '23 18:07 see24