profandyfield / discovr

discovr package for R to accompany Discovering Statistics Using R and RStudio
131 stars 25 forks source link

discover_08: Deprecated function in `across` #17

Closed cmadland closed 6 months ago

cmadland commented 6 months ago

https://github.com/profandyfield/discovr/blob/342aad3d3d09d7b4424bfb31527828fd0ccc3975/inst/tutorials/discovr_08/discovr_08.Rmd#L986

The function itself is not deprecated, but the use of the function across without .cols is deprecated in dplyr 1.1.1.

When trying to replicate the function on line 986 in my own .qmd file in VS Code, I get an error, but it only displays once every 8 hours.

VS Code version

Version: 1.86.2 (Universal)
Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
Date: 2024-02-13T19:42:13.651Z
Electron: 27.2.3
ElectronBuildId: 26908389
Chromium: 118.0.5993.159
Node.js: 18.17.1
V8: 11.8.172.18-electron.0
OS: Darwin x64 22.6.0

dplyr version

Type: Package
Package: dplyr
Title: A Grammar of Data Manipulation
Version: 1.1.4
Authors@R: c(
    person("Hadley", "Wickham", , "hadley@posit.co", role = c("aut", "cre"),
           comment = c(ORCID = "0000-0003-4757-117X")),
    person("Romain", "François", role = "aut",
           comment = c(ORCID = "0000-0002-2444-4226")),
    person("Lionel", "Henry", role = "aut"),
    person("Kirill", "Müller", role = "aut",
           comment = c(ORCID = "0000-0002-1416-3412")),
    person("Davis", "Vaughan", , "davis@posit.co", role = "aut",
           comment = c(ORCID = "0000-0003-4777-038X")),
    person("Posit Software, PBC", role = c("cph", "fnd"))
  )
Description: A fast, consistent tool for working with data frame like
    objects, both in memory and out of memory.
License: MIT + file LICENSE
URL: https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr
BugReports: https://github.com/tidyverse/dplyr/issues
Depends: R (>= 3.5.0)
Imports: cli (>= 3.4.0), generics, glue (>= 1.3.2), lifecycle (>=
        1.0.3), magrittr (>= 1.5), methods, pillar (>= 1.9.0), R6,
        rlang (>= 1.1.0), tibble (>= 3.2.0), tidyselect (>= 1.2.0),
        utils, vctrs (>= 0.6.4)
Suggests: bench, broom, callr, covr, DBI, dbplyr (>= 2.2.1), ggplot2,
        knitr, Lahman, lobstr, microbenchmark, nycflights13, purrr,
        rmarkdown, RMySQL, RPostgreSQL, RSQLite, stringi (>= 1.7.6),
        testthat (>= 3.1.5), tidyr (>= 1.3.0), withr
VignetteBuilder: knitr
Config/Needs/website: tidyverse, shiny, pkgdown, tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
NeedsCompilation: yes
Packaged: 2023-11-16 21:48:56 UTC; hadleywickham
Author: Hadley Wickham [aut, cre] (<https://orcid.org/0000-0003-4757-117X>),
  Romain François [aut] (<https://orcid.org/0000-0002-2444-4226>),
  Lionel Henry [aut],
  Kirill Müller [aut] (<https://orcid.org/0000-0002-1416-3412>),
  Davis Vaughan [aut] (<https://orcid.org/0000-0003-4777-038X>),
  Posit Software, PBC [cph, fnd]
Maintainer: Hadley Wickham <hadley@posit.co>
Repository: CRAN
Date/Publication: 2023-11-17 16:50:02 UTC
Built: R 4.2.0; x86_64-apple-darwin17.0; 2023-12-21 16:49:49 UTC; unix
Archs: dplyr.so.dSYM

RStudio version

Version 2023.12.1+402 (2023.12.1+402)

R Version

4.2.3

profandyfield commented 6 months ago

Thanks for pointing this out. For now, add .cols = everything() to the code:

soc_anx_tib |>
  dplyr::summarise(
    across(.cols = everything(), .fns = list(valid = ~sum(!is.na(.x)), missing = ~sum(is.na(.x))), .names = "{.col}_{.fn}")
    )

I've changed this in my raw code so it will be updated on gitHub next time I do a push.