r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
508 stars 138 forks source link

warning with rlang `0.4.0` #822

Closed IndrajeetPatil closed 5 years ago

IndrajeetPatil commented 5 years ago

I am trying to convert a non-tidy function to a tidy one and I am getting the following warning once per session-

library(tidyverse)

# custom function to run within-subjects ANOVA

aov_fun <- function(data, x, y, id) {
  # getting data in format that `ez` expects
  df <- data %>%
    dplyr::mutate_if(
      .tbl = .,
      .predicate = purrr::is_bare_character,
      .funs = as.factor
    ) %>%
    dplyr::mutate(.data = ., {{ id }} := as.factor({{ id }})) %>%
    tibble::as_tibble(.)

  # running anova
  rlang::eval_tidy(rlang::expr(ez::ezANOVA(
    data = df,
    dv = {{ y }},
    wid = {{ id }},
    within = {{ x }}
  )))
}

# using the function
aov_fun(WRS2::WineTasting, Wine, Taste, Taster)

#> Warning: Using `as.character()` on a quosure is deprecated as of rlang 0.3.0.
#> Please use `as_label()` or `as_name()` instead.
#> This warning is displayed once per session.

#> $ANOVA
#>   Effect DFn DFd        F           p p<.05        ges
#> 2   Wine   2  42 6.288308 0.004084101     * 0.02026075
#> 
#> $`Mauchly's Test for Sphericity`
#>   Effect         W          p p<.05
#> 2   Wine 0.7071776 0.03128132     *
#> 
#> $`Sphericity Corrections`
#>   Effect       GGe       p[GG] p[GG]<.05       HFe       p[HF] p[HF]<.05
#> 2   Wine 0.7735015 0.008439799         * 0.8233709 0.007188822         *

Created on 2019-08-13 by the reprex package (v0.3.0)

How can I get rid of this warning?

> Warning: Using as.character() on a quosure is deprecated as of rlang 0.3.0.

> Please use as_label() or as_name() instead.

> This warning is displayed once per session.

Session info ``` r devtools::session_info() #> - Session info ---------------------------------------------------------- #> setting value #> version R version 3.6.1 (2019-07-05) #> os Windows 10 x64 #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate English_United States.1252 #> ctype English_United States.1252 #> tz America/New_York #> date 2019-08-13 #> #> - Packages -------------------------------------------------------------- #> package * version date lib #> abind 1.4-5 2016-07-21 [1] #> assertthat 0.2.1 2019-03-21 [1] #> backports 1.1.4 2019-04-10 [1] #> boot 1.3-23 2019-07-05 [1] #> broom 0.5.2.9002 2019-08-08 [1] #> callr 3.3.1 2019-07-18 [1] #> car 3.0-3 2019-05-27 [1] #> carData 3.0-2 2018-09-30 [1] #> cellranger 1.1.0 2016-07-27 [1] #> cli 1.1.0 2019-03-19 [1] #> colorspace 1.4-1 2019-03-18 [1] #> crayon 1.3.4 2017-09-16 [1] #> curl 4.0 2019-07-22 [1] #> data.table 1.12.2 2019-04-07 [1] #> desc 1.2.0 2019-04-03 [1] #> devtools 2.1.0 2019-07-06 [1] #> digest 0.6.20 2019-07-04 [1] #> dplyr * 0.8.3 2019-07-04 [1] #> evaluate 0.14 2019-05-28 [1] #> ez 4.4-0 2016-11-02 [1] #> forcats * 0.4.0 2019-02-17 [1] #> foreign 0.8-71 2018-07-20 [2] #> fs 1.3.1 2019-05-06 [1] #> generics 0.0.2 2019-03-05 [1] #> ggplot2 * 3.2.1 2019-08-10 [1] #> glue 1.3.1 2019-03-12 [1] #> gtable 0.3.0 2019-03-25 [1] #> haven 2.1.1 2019-07-04 [1] #> highr 0.8 2019-03-20 [1] #> hms 0.5.0 2019-07-09 [1] #> htmltools 0.3.6 2017-04-28 [1] #> httr 1.4.1 2019-08-05 [1] #> jsonlite 1.6 2018-12-07 [1] #> knitr 1.24 2019-08-08 [1] #> lattice 0.20-38 2018-11-04 [2] #> lazyeval 0.2.2 2019-03-15 [1] #> lifecycle 0.1.0 2019-08-01 [1] #> lme4 1.1-21 2019-03-05 [1] #> lubridate 1.7.4 2018-04-11 [1] #> magrittr 1.5 2014-11-22 [1] #> MASS 7.3-51.4 2019-03-31 [1] #> Matrix 1.2-17 2019-03-22 [1] #> mc2d 0.1-18 2017-03-06 [1] #> memoise 1.1.0 2017-04-21 [1] #> mgcv 1.8-28 2019-03-21 [1] #> minqa 1.2.4 2014-10-09 [1] #> modelr 0.1.5 2019-08-08 [1] #> munsell 0.5.0 2018-06-12 [1] #> mvtnorm 1.0-11 2019-06-19 [1] #> nlme 3.1-140 2019-05-12 [2] #> nloptr 1.2.1 2018-10-03 [1] #> openxlsx 4.1.0.1 2019-05-28 [1] #> pillar 1.4.2 2019-06-29 [1] #> pkgbuild 1.0.4 2019-08-05 [1] #> pkgconfig 2.0.2 2018-08-16 [1] #> pkgload 1.0.2 2018-10-29 [1] #> plyr 1.8.4 2016-06-08 [1] #> prettyunits 1.0.2 2015-07-13 [1] #> processx 3.4.1 2019-07-18 [1] #> ps 1.3.0 2018-12-21 [1] #> purrr * 0.3.2 2019-03-15 [1] #> R6 2.4.0 2019-02-14 [1] #> Rcpp 1.0.2 2019-07-25 [1] #> readr * 1.3.1 2018-12-21 [1] #> readxl 1.3.1 2019-03-13 [1] #> remotes 2.1.0 2019-06-24 [1] #> reshape 0.8.8 2018-10-23 [1] #> reshape2 1.4.3 2017-12-11 [1] #> rio 0.5.16 2018-11-26 [1] #> rlang 0.4.0 2019-06-25 [1] #> rmarkdown 1.14.3 2019-08-02 [1] #> rprojroot 1.3-2 2018-01-03 [1] #> rvest 0.3.4 2019-05-15 [1] #> scales 1.0.0 2018-08-09 [1] #> sessioninfo 1.1.1 2018-11-05 [1] #> stringi 1.4.3 2019-03-12 [1] #> stringr * 1.4.0 2019-02-10 [1] #> testthat 2.2.1 2019-07-25 [1] #> tibble * 2.1.3 2019-06-06 [1] #> tidyr * 0.8.99.9000 2019-08-11 [1] #> tidyselect 0.2.5 2018-10-11 [1] #> tidyverse * 1.2.1 2017-11-14 [1] #> usethis 1.5.1.9000 2019-07-27 [1] #> vctrs 0.2.0 2019-07-05 [1] #> withr 2.1.2 2018-03-15 [1] #> WRS2 1.0-0 2019-06-05 [1] #> xfun 0.8 2019-06-25 [1] #> xml2 1.2.2 2019-08-09 [1] #> yaml 2.2.0 2018-07-25 [1] #> zeallot 0.1.0 2018-01-28 [1] #> zip 2.0.3 2019-07-03 [1] #> source #> CRAN (R 3.5.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> local #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.1) #> CRAN (R 3.5.3) #> Github (r-lib/desc@c860e7b) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.3) #> CRAN (R 3.5.2) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> Github (r-lib/generics@c15ac43) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> Github (rstudio/rmarkdown@37bcb8f) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.6.0) #> Github (tidyverse/tidyr@908da2c) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> Github (r-lib/usethis@b241420) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> R-Forge (R 3.6.0) #> CRAN (R 3.6.0) #> CRAN (R 3.6.1) #> CRAN (R 3.5.1) #> CRAN (R 3.5.1) #> CRAN (R 3.6.0) #> #> [1] C:/Users/inp099/Documents/R/win-library/3.6 #> [2] C:/Program Files/R/R-3.6.1/library ```
IndrajeetPatil commented 5 years ago

Ah, replacing {{y}} with !!rlang::ensym(y) gets rid of this warning.

lionel- commented 5 years ago

Probably ez::ezANOVA() uses as.character() on quosures, which used to have undocumented behaviour (it dispatched to the formula method which was unintended).