Closed aaron-horowitz closed 2 years ago
Could you please make a reprex with the reprex package, just to make sure there's nothing else going on in your session?
And are you restarting your R session after installing magrittr?
Having the same issue as @aaron-horowitz. Not sure I can give a better reprex atm (sorry).
I did restart R-Studio after installing the package, same issue.
Until it is fixed, there are two workarounds for anyone encountering this now:
Revert to older magrittr
version with:
devtools::install_version("magrittr", version = "1.5.0", repos = "http://cran.us.r-project.org")
or, Manually assign %>%
:
`%>%` <- magrittr::`%>%\`
R version 4.0.2 (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.10 Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=en_IL.UTF-8 LC_NUMERIC=C LC_TIME=en_IL.UTF-8 LC_COLLATE=en_IL.UTF-8 [5] LC_MONETARY=en_IL.UTF-8 LC_MESSAGES=en_IL.UTF-8 LC_PAPER=en_IL.UTF-8 LC_NAME=en_IL.UTF-8 [9] LC_ADDRESS=en_IL.UTF-8 LC_TELEPHONE=en_IL.UTF-8 LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=en_IL.UTF-8 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] shinydashboardPlus_0.7.5 shinyWidgets_0.5.4 shinydashboard_0.7.1 openxlsx_4.2.3 [5] httr_1.4.2 jsonlite_1.7.2 e1071_1.7-4 DMwR_0.4.1 [9] AUC_0.3.0 caret_6.0-86 lattice_0.20-41 glmnet_4.0-2 [13] Matrix_1.2-18 lsa_0.73.2 text2vec_0.6 SnowballC_0.7.0 [17] qdap_2.4.3 RColorBrewer_1.1-2 qdapTools_1.3.5 qdapRegex_0.7.2 [21] qdapDictionaries_1.0.7 tm_0.7-8 NLP_0.2-1 d3Tree_0.2.2 [25] shinyPagerUI_0.2.0 tidytext_0.2.6 highcharter_0.8.2 vip_0.2.2 [29] ggthemes_4.2.0 pool_0.1.5 odbc_1.3.0 htmlTable_2.1.0 [33] compareDF_2.3.0 DT_0.16 forcats_0.5.0 stringr_1.4.0 [37] dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2 [41] tibble_3.0.4 tidyverse_1.3.0 rsample_0.0.8 caTools_1.18.0 [45] wesanderson_0.3.6 anytime_0.3.9 waffle_0.7.0 ggplot2_3.3.2 [49] config_0.3 shiny_1.5.0 loaded via a namespace (and not attached): [1] reticulate_1.18 tidyselect_1.1.0 htmlwidgets_1.5.3 pROC_1.16.2 devtools_2.3.2 [6] munsell_0.5.0 codetools_0.2-16 chron_2.3-56 future_1.21.0 withr_2.3.0 [11] colorspace_2.0-0 knitr_1.30 rstudioapi_0.13 ROCR_1.0-11 stats4_4.0.2 [16] tensorflow_2.2.0 rJava_0.9-13 Rttf2pt1_1.3.8 TTR_0.24.2 listenv_0.8.0 [21] slam_0.1-48 lgr_0.4.1 openNLPdata_1.5.3-4 bit64_4.0.5 rprojroot_2.0.2 [26] parallelly_1.22.0 vctrs_0.3.5 generics_0.1.0 ipred_0.9-9 xfun_0.19 [31] float_0.2-4 rlist_0.4.6.1 R6_2.5.0 bitops_1.0-6 assertthat_0.2.1 [36] promises_1.1.1 scales_1.1.1 nnet_7.3-14 gtable_0.3.0 globals_0.14.0 [41] processx_3.4.5 timeDate_3043.102 rlang_0.4.9 splines_4.0.2 extrafontdb_1.0 [46] ModelMetrics_1.2.2.2 wordcloud_2.6 broom_0.7.2 checkmate_2.0.0 abind_1.4-5 [51] yaml_2.2.1 reshape2_1.4.4 modelr_0.1.8 crosstalk_1.1.0.1 backports_1.2.1 [56] rsconnect_0.8.16 httpuv_1.5.4 quantmod_0.4.18 tokenizers_0.2.1 extrafont_0.17 [61] lava_1.6.8.1 tools_4.0.2 usethis_2.0.0 ellipsis_0.3.1 sessioninfo_1.1.1 [66] Rcpp_1.0.5 plyr_1.8.6 base64enc_0.1-3 RCurl_1.98-1.2 ps_1.5.0 [71] prettyunits_1.1.1 rpart_4.1-15 openNLP_0.2-7 zoo_1.8-8 haven_2.3.1 [76] fs_1.5.0 furrr_0.2.1 magrittr_2.0.1 data.table_1.13.4 reprex_0.3.0 [81] RBERT_0.1.11 mlapi_0.1.0 whisker_0.4 pkgload_1.1.0 hms_0.5.3 [86] mime_0.9 xtable_1.8-4 RhpcBLASctl_0.20-137 XML_3.99-0.5 readxl_1.3.1 [91] gridExtra_2.3 shape_1.4.5 tfruns_1.4 testthat_3.0.0 compiler_4.0.2 [96] crayon_1.3.4 gender_0.5.4 htmltools_0.5.0 later_1.1.0.1 venneuler_1.1-0 [101] lubridate_1.7.9.2 DBI_1.1.0 dbplyr_2.0.0 MASS_7.3-52 cli_2.2.0 [106] gower_0.2.2 parallel_4.0.2 igraph_1.2.6 pkgconfig_2.0.3 rsparse_0.4.0 [111] recipes_0.1.15 xml2_1.3.2 foreach_1.5.1 prodlim_2019.11.13 rvest_0.3.6 [116] janeaustenr_0.1.5 callr_3.5.1 digest_0.6.27 cellranger_1.1.0 curl_4.3 [121] nlme_3.1-149 lifecycle_0.2.0 desc_1.2.0 fansi_0.4.1 pillar_1.4.7 [126] fastmap_1.0.1 plotrix_3.7-8 pkgbuild_1.1.0 survival_3.2-3 glue_1.4.2 [131] xts_0.12.1 remotes_2.2.0 zip_2.1.1 iterators_1.0.13 bit_4.0.4 [136] class_7.3-17 stringi_1.5.3 blob_1.2.1 memoise_1.1.0
@alexeyza can you please use https://reprex.tidyverse.org to produce a reprex? Or at least include the code that is giving you the error? I would like to figure out the root cause of the issue before recommending fixes.
While creating a reprex, I noticed that it is probably happening due to masking (by qdap
in my case). I only noticed this masking now. I wonder why wasn't this an issue in magrittr 1.5.0
. Loading qdap
first and then tidyverse
seems to not have this issue.
I'll need to figure out a way to maintain order of loading packages (when involving a multi-module Shiny app), and make sure qdap
is loaded before tidyverse
. At the moment, using global.R
to guarantee qadp
is loaded early on.
I wonder if this is the same for @aaron-horowitz
Here's the reprex:
iris %>% group_by(Species) %>% mutate(avg = mean(Sepal.Length))
#> Error in iris %>% group_by(Species) %>% mutate(avg = mean(Sepal.Length)): could not find function "%>%"
library(tidyverse)
iris %>% group_by(Species) %>% mutate(avg = mean(Sepal.Length))
#> # A tibble: 150 x 6
#> # Groups: Species [3]
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species avg
#> <dbl> <dbl> <dbl> <dbl> <fct> <dbl>
#> 1 5.1 3.5 1.4 0.2 setosa 5.01
#> 2 4.9 3 1.4 0.2 setosa 5.01
#> 3 4.7 3.2 1.3 0.2 setosa 5.01
#> 4 4.6 3.1 1.5 0.2 setosa 5.01
#> 5 5 3.6 1.4 0.2 setosa 5.01
#> 6 5.4 3.9 1.7 0.4 setosa 5.01
#> 7 4.6 3.4 1.4 0.3 setosa 5.01
#> 8 5 3.4 1.5 0.2 setosa 5.01
#> 9 4.4 2.9 1.4 0.2 setosa 5.01
#> 10 4.9 3.1 1.5 0.1 setosa 5.01
#> # … with 140 more rows
library(qdap)
#> Loading required package: qdapDictionaries
#> Loading required package: qdapRegex
#>
#> Attaching package: 'qdapRegex'
#> The following object is masked from 'package:dplyr':
#>
#> explain
#> The following object is masked from 'package:ggplot2':
#>
#> %+%
#> Loading required package: qdapTools
#>
#> Attaching package: 'qdapTools'
#> The following object is masked from 'package:dplyr':
#>
#> id
#> Loading required package: RColorBrewer
#>
#> Attaching package: 'qdap'
#> The following object is masked from 'package:forcats':
#>
#> %>%
#> The following object is masked from 'package:stringr':
#>
#> %>%
#> The following object is masked from 'package:dplyr':
#>
#> %>%
#> The following object is masked from 'package:purrr':
#>
#> %>%
#> The following object is masked from 'package:tidyr':
#>
#> %>%
#> The following object is masked from 'package:tibble':
#>
#> %>%
#> The following objects are masked from 'package:base':
#>
#> Filter, proportions
iris %>% group_by(Species) %>% mutate(avg = mean(Sepal.Length))
#> Error in split_chain(match.call(), env = env): could not find function "split_chain"
Created on 2020-12-13 by the reprex package (v0.3.0)
You’ll notice that there are a bunch of warning about masking %>%
— the root cause is probably that qdap copied in the source of %>%
rather than re-exporting it.
I see this as the way qdap uses the pipe. What is appropriate way to re-export %>%?
https://github.com/trinker/qdap/blob/master/R/chaining.R
On Sun, Dec 13, 2020 at 10:43 AM Hadley Wickham notifications@github.com wrote:
You’ll notice that there are a bunch of warning about masking %>% — the root cause is probably that qdap copied in the source of %>% rather than re-exporting it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tidyverse/magrittr/issues/238#issuecomment-744050446, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2OABRE5LBFHT3KVEIPRIDSUUDO7ANCNFSM4UYXYCDA .
Could you please make a reprex with the reprex package, just to make sure there's nothing else going on in your session?
And are you restarting your R session after installing magrittr?
Yes re restarting R session after installing magrittr. I couldn't figure out how to make a reprex with the reprex package because I can only get the error to occur when I'm inside a package function (internal package, happy to share with you Hadley but it's not pretty enough to open source). I don't re-export the pipe in the package, I just use it internally.
Hi everyone,
From what I've seen in this thread, the issue is indeed caused by qdap copying the magrittr pipe in their package. This means that when there a new version of magrittr is out, the old code source is still hard-coded in qdap.
To fix this on your end, just delete the qdap package and reinstall it. This will copy the new version of magrittr in the package. If qdap hasn't been rebuilt on CRAN yet (unlikely I think) then you'll need to reinstall from source instead of binary.
To fix this for good in qdap, the author (cc @trinker) should remove the <-
assignment. In general, never use <-
with objects from foreign packages. See how we reexport the magrittr pipe from dplyr for example https://github.com/tidyverse/dplyr/blob/166aed15279d233b3118e2abe90a3ac3cb156947/R/utils.r#L1-L3
Here are some general resources that seem relevant to what went wrong here:
usethis::use_pipe()
implements the recommended way to use %>%
inside a package, either just internally or internally+also re-exportingThank you! I suspect other package others made the <-
assignment incorrectly, so I hope this thread is a useful reference when it comes up for others.
Hi folks,
I had originally thought this issue was specific to just me so I didn't file an issue report, but I see based on this twitter thread I am not alone.
The error appears to occur with the latest version of magrittr and an internal function
magrittr:::split_chain
. If I force install v1.5 viadevtools::install_github('tidyverse/magrittr@v1.5')
the issue is resolved.I'm struggling to come up with a reprex for this, but if I try to use a pipe on something as simple as below in the context of an existing function within a package (where the package accesses the pipe via
%>% = magrittr::
%>%` in a utils.R file):While browsing within that function, the
%>%
is clearly referencing the old version of the pipe:While outside of debug / the package itself, assigning
%>%
= magrittr::%>%
produces the new version version of the pipe correctly.Session info in details:
I'm hoping someone else who's having this issue can provide a cleaner reprex.