简体   繁体   中英

Python/rpy2 does not recognize %>% pipe in r code

I have a Python script that will pass dataframes into an R package and get the results. The R script works as expected in R studio.

However I cannot get it to wokr when executing through python/rpy2.

rpy2.rinterface_lib.embedded.RRuntimeError: Error in ataframe d%>% dplyr::rename(domain = Domain, variable = Variable,  : 
  could not find function "%>%"

Is there a way to get this to work when executing through python? Rewriting the code to not use %>% is working but will require a lot of rewriting that I would prefer to avoid if possible.

I've tried making sure the dplyr library is in every script. I've confirmed its installed prior to running the python script.

I have not found any examples of this issue while using rpy2/python.

%>% is from the magrittr package. If you have R version 4.1 or later you can use the native |> pipe instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM