how to import with roxygen packages the pipe operator %>% from dplyr

我怕爱的太早我们不能终老 提交于 2020-01-04 05:53:42

问题


I want to build a package with some functions i wrote. Now my problem is, that i cannot use the pipe-operator %>% with dplyr. I create the package with roxygen2.

If i write the dplyr-commands without %>%, everything works fine.

inside the code:

#'
#' @import dplyr readr mailR writexl
#' @importFrom dplyr %>%
#' @name %>%
#' 
#' @export
#'

I wrote:

DESCRIPTION

LazyData: true
RoxygenNote: 6.0.1
Imports: dplyr 

roxygen2 generates:

NAMESPACE

...
importFrom(dplyr,"%>%")
...

回答1:


Usually you would import the pipe operator from magrittr.

You could add a file to the R dir of your package that looks somewhat like this:

#' Pipe
#'
#' Put description here
#'
#' @importFrom magrittr %>%
#' @name %>%
#' @rdname pipe
#' @export
#' @param lhs,rhs specify what lhs and rhs are
#' @examples
#' # some examples if you want to highlight the usage in the package
NULL

In addition you have to add magrittr to your imports in the description file of your package.



来源:https://stackoverflow.com/questions/46974439/how-to-import-with-roxygen-packages-the-pipe-operator-from-dplyr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!