在我的过程中,我需要执行很多dplyr::inner_join
s。认为是解释here我可以定义一个定制的管道运营商为它:
library(tidyverse)
library(rlang)
df1 <- tibble(a = 1:10, b = 11:20)
df2 <- tibble(a = 1:10, c = 21:30)
`%J>%` <- function(lhs, rhs){
inner_join(lhs, rhs)
}
df1 %J>% df2
这工作正常,我也得到:
Joining, by = "a" # A tibble: 10 x 3 a b c <int> <int> <int> 1 1 11 21 2 2 12 22 3 3 13 23 4 4 14 24 5 5 15 25 6 6 16 26 7 7 17 27 8 8 18 28 9 9 19 29 10 10 20 30
但后来又警告:
Warning message: `chr_along()` is soft-deprecated as of rlang 0.2.0. This warning is displayed once per session.
情节变得如果我不包括在所有library(rlang)
(在一个新的会话),在这种情况下,我没有得到任何警告:
library(tidyverse)
df1 <- tibble(a = 1:10, b = 11:20)
df2 <- tibble(a = 1:10, c = 21:30)
`%J>%` <- function(lhs, rhs){
inner_join(lhs, rhs)
}
df1 %J>% df2
很显然,我没有包括library(rlang)
所有在这个例子中,但如果我这样做 - 这是一个奇怪的警告。它在哪里从哪里来,以及如何避免它,如果我想包括library(rlang)
?
sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17134) Matrix products: default locale: [1] LC_COLLATE=English_Israel.1252 LC_CTYPE=English_Israel.1252 LC_MONETARY=English_Israel.1252 LC_NUMERIC=C LC_TIME=English_Israel.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rlang_0.3.0.1 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.6 purrr_0.2.5 readr_1.1.1 tidyr_0.8.1 tibble_1.4.2 ggplot2_3.1.0 tidyverse_1.2.1 loaded via a namespace (and not attached): [1] Rcpp_0.12.19 cellranger_1.1.0 pillar_1.3.0 compiler_3.5.1 plyr_1.8.4 bindr_0.1.1 tools_3.5.1 packrat_0.4.9-3 jsonlite_1.5 lubridate_1.7.4 nlme_3.1-137 [12] gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.2 cli_1.0.1 rstudioapi_0.8 haven_1.1.2 bindrcpp_0.2.2 withr_2.1.2 xml2_1.2.0 httr_1.3.1 hms_0.4.2 [23] grid_3.5.1 tidyselect_0.2.4 glue_1.3.0 R6_2.2.2 fansi_0.3.0 readxl_1.1.0 modelr_0.1.2 magrittr_1.5 backports_1.1.2 scales_1.0.0 rvest_0.3.2 [34] assertthat_0.2.0 colorspace_1.3-2 utf8_1.1.4 stringi_1.2.4 lazyeval_0.2.1 munsell_0.5.0 broom_0.5.0 crayon_1.3.4
从你的描述,我要说的是,如果加载rlang
作为tidyverse
的一部分(即只需加载tidyverse
),则R将使用诗句的rlang
这是自动更新whithin的诗句。如果加载tidyverse
先rlang
,则R将使用最后一个看到的,这是你手动加载的一个。因此,如果您没有手动更新rlang
然后它会给警告。这个问题应该走开如果您手动更新rlang
。