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

calc_light_merged throws deprecated error #434

Open
spencer-tassone opened this issue Oct 22, 2024 · 1 comment
Open

calc_light_merged throws deprecated error #434

spencer-tassone opened this issue Oct 22, 2024 · 1 comment

Comments

@spencer-tassone
Copy link

Brief problem description

I am trying to use the calc_light_merged function to model PAR based on observed PAR and the smoothed PAR produced with calc_light. However, the calc_light_merged function produces an error caused by a function that is deprecated in dplyr (rename_vars). Is there a work around for this issue?

# 1. Load libraries ----
library(tidyverse)
library(nasapower)
library(streamMetabolizer)

# 2. Download shortwave radiation from NASA POWER ----
nasa_par <- get_power(
  community = 'ag',
  pars = c('ALLSKY_SFC_PAR_TOT'), # All Sky Surface PAR Total (W/m^2) 
  temporal_api = 'hourly',
  lonlat = c(-78.6, 38.7),
  dates = '2010-09-19')

# 3. Some data wrangling to create the 2-column data frame needed for calc_light_merged ----
nasa_par_df <- nasa_par %>%
  mutate(dateTime = make_datetime(year = YEAR,
                                  month = MO,
                                  day = DY,
                                  hour = HR),
         solar.time = calc_solar_time(dateTime, -78.6), # throws a warning but still works
         light = convert_SW_to_PAR(ALLSKY_SFC_PAR_TOT)) %>% 
  select(solar.time, light) %>% 
  data.frame()
#> Warning: There was 1 warning in `mutate()`.
#> ℹ In argument: `solar.time = calc_solar_time(dateTime, -78.6)`.
#> Caused by warning in `lookup_timezone()`:
#> ! Google timezone lookup now requires an API key; see http://g.co/dev/maps-no-account or provide the timezone

max_PAR_value <- max(nasa_par_df$light, na.rm = TRUE)

# 4. Apply calc_light_merged ----
light_mod <- nasa_par_df %>%
  mutate(light = calc_light_merged(PAR.obs = nasa_par_df,
                                   solar.time = solar.time,
                                   latitude = 38.7,
                                   longitude = -78.6,
                                   max.PAR = max_PAR_value))
#> Error in `mutate()`:
#> ℹ In argument: `light = calc_light_merged(...)`.
#> Caused by error:
#> ! error in evaluating the argument 'object' in selecting a method for function 'deunitted': `rename_vars()` was deprecated in dplyr 0.8.4 and is now defunct.
#> ℹ Please use `tidyselect::vars_rename()` instead.

Created on 2024-10-22 with reprex v2.1.1

devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14 ucrt)
#>  os       Windows 11 x64 (build 22631)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/New_York
#>  date     2024-10-22
#>  pandoc   3.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cachem        1.1.0   2024-05-16 [1] CRAN (R 4.4.1)
#>  cli           3.6.3   2024-06-21 [1] CRAN (R 4.4.1)
#>  devtools      2.4.5   2022-10-11 [1] CRAN (R 4.4.1)
#>  digest        0.6.36  2024-06-23 [1] CRAN (R 4.4.1)
#>  ellipsis      0.3.2   2021-04-29 [1] CRAN (R 4.4.1)
#>  evaluate      0.24.0  2024-06-10 [1] CRAN (R 4.4.1)
#>  fastmap       1.2.0   2024-05-15 [1] CRAN (R 4.4.1)
#>  fs            1.6.4   2024-04-25 [1] CRAN (R 4.4.1)
#>  glue          1.7.0   2024-01-09 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1 2024-04-04 [1] CRAN (R 4.4.1)
#>  htmlwidgets   1.6.4   2023-12-06 [1] CRAN (R 4.4.1)
#>  httpuv        1.6.15  2024-03-26 [1] CRAN (R 4.4.1)
#>  knitr         1.48    2024-07-07 [1] CRAN (R 4.4.1)
#>  later         1.3.2   2023-12-06 [1] CRAN (R 4.4.1)
#>  lifecycle     1.0.4   2023-11-07 [1] CRAN (R 4.4.1)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.4.1)
#>  memoise       2.0.1   2021-11-26 [1] CRAN (R 4.4.1)
#>  mime          0.12    2021-09-28 [1] CRAN (R 4.4.0)
#>  miniUI        0.1.1.1 2018-05-18 [1] CRAN (R 4.4.1)
#>  pkgbuild      1.4.4   2024-03-17 [1] CRAN (R 4.4.1)
#>  pkgload       1.4.0   2024-06-28 [1] CRAN (R 4.4.1)
#>  profvis       0.3.8   2023-05-02 [1] CRAN (R 4.4.1)
#>  promises      1.3.0   2024-04-05 [1] CRAN (R 4.4.1)
#>  purrr         1.0.2   2023-08-10 [1] CRAN (R 4.4.1)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.4.1)
#>  Rcpp          1.0.12  2024-01-09 [1] CRAN (R 4.4.1)
#>  remotes       2.5.0   2024-03-17 [1] CRAN (R 4.4.1)
#>  reprex        2.1.1   2024-07-06 [1] CRAN (R 4.4.1)
#>  rlang         1.1.4   2024-06-04 [1] CRAN (R 4.4.1)
#>  rmarkdown     2.27    2024-05-17 [1] CRAN (R 4.4.1)
#>  rstudioapi    0.16.0  2024-03-24 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.4.1)
#>  shiny         1.8.1.1 2024-04-02 [1] CRAN (R 4.4.1)
#>  stringi       1.8.4   2024-05-06 [1] CRAN (R 4.4.0)
#>  stringr       1.5.1   2023-11-14 [1] CRAN (R 4.4.1)
#>  urlchecker    1.0.1   2021-11-30 [1] CRAN (R 4.4.1)
#>  usethis       2.2.3   2024-02-19 [1] CRAN (R 4.4.1)
#>  vctrs         0.6.5   2023-12-01 [1] CRAN (R 4.4.1)
#>  withr         3.0.0   2024-01-16 [1] CRAN (R 4.4.1)
#>  xfun          0.45    2024-06-16 [1] CRAN (R 4.4.1)
#>  xtable        1.8-4   2019-04-21 [1] CRAN (R 4.4.1)
#>  yaml          2.3.9   2024-07-05 [1] CRAN (R 4.4.1)
#> 
#>  [1] C:/Users/stassone/AppData/Local/Programs/R/R-4.4.1/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Created on 2024-10-22 with reprex v2.1.1

@spencer-tassone spencer-tassone changed the title calc_light_merged not working due to calc_light_merged throws deprecated error Oct 22, 2024
@robohall
Copy link

robohall commented Oct 23, 2024 via email

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

No branches or pull requests

2 participants