pipe operator not working

The pipe operator is not working. I get this error message, (could not find function "%>%"). I have installed and loaded tidyverse. I even installed and loaded both 'dplyr' and 'magrittr' separately with no success. Here is a section of the code

may_21<-X202105_divvy_tripdata %>% mutate(ride_time=ended_at-started_at)

Restart your R session and load maggritr do you get any error message or warning while doing so? My intention with this is to gather more information about your issue.

I have done so but the problem remains. Here is the error message, 'could not find function "%>%"'

please first load your libraries and run your code to trigger your issue ... then please provide us the output from calling the sessionInfo() function.

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.4 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
[1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
[4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
[7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] rstudioapi_0.13 knitr_1.39 magrittr_2.0.3 tidyselect_1.1.2
[5] R6_2.5.1 rlang_1.0.2 fastmap_1.1.0 fansi_1.0.3
[9] dplyr_1.0.9 tools_4.2.1 xfun_0.31 utf8_1.2.2
[13] cli_3.3.0 DBI_1.1.2 dbplyr_2.1.1 htmltools_0.5.2
[17] ellipsis_0.3.2 yaml_2.3.5 assertthat_0.2.1 digest_0.6.29
[21] tibble_3.1.7 lifecycle_1.0.1 crayon_1.5.1 purrr_0.3.4
[25] vctrs_0.4.1 glue_1.6.2 evaluate_0.15 rmarkdown_2.14
[29] compiler_4.2.1 pillar_1.7.0 generics_0.1.2 pkgconfig_2.0.3

Thanks, in this same state, can you run the following 2 commands and share the output

getAnywhere(`%>%`)
magrittr::`%>%`

p.s. the above is overkill, I can see that from sessionInfo loaded via a namespace (and not attached): contains both magrittr and dplyr.
This tells me that you have not use library(dplyr) nor library(magrittr) to load them, if you had they would be listed under 'attached_packages', and you have no attached packages, impliying you didnt make any library()/require() statements in your session.

Just a sec. Correct me if I am wrong, given that I am now learning R. I am using r markdown. The first chunk has the following code:

          library(janitor)
          library(skimr)
          library(lubridate)
          library(dplyr)
          library(magrittr)```
What could I be doing wrong that magrittr and dplyr do not attach yet I have used the library() function on them?

I think you omitted the {r} part of the start of the rchunk
i.e.

```{r}
library(dplyr)
```

if you omit {r} its just a text chunk

1 Like

Oh my God!!! That seems to have been the problem. I did not know that, now solved. Thank you very much!!!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.