Conte-Ecology / conteStreamTemperature

Package for cleaning and analyzing stream daily stream temperature
MIT License
1 stars 1 forks source link

Bug in dplyr within QAQC code #28

Closed djhocking closed 9 years ago

djhocking commented 9 years ago

The obs_freq function in the QAQC.R script should use

median_obs <- obs_per_day %>%
    #dplyr::mutate(series_id_alt = paste0(series_id, "-", "a")) %>%
    dplyr::group_by(series_id) %>%
    #dplyr::mutate(obs_per_day = ifelse(is.na(obs_per_day), NA_integer_, obs_per_day)) %>%
    dplyr::summarise(median_freq = median(obs_per_day, na.rm = T), min_n90 = median_freq*0.9)

but there is an bug in dplyr that prevents this for some datasets. See github issue: https://github.com/hadley/dplyr/issues/893

for now I will use the mean in place of the median but it should be change when dplyr is fixed.

djhocking commented 9 years ago

https://github.com/hadley/dplyr/issues/893#issuecomment-91353361

This doesn't seem to happen if you multiply the median calculation by a float. The following works fine:

summarise(median = median(x) * 1.0)