如何使用roxygen包导入dplyr中的管道运算符%&%;% [英] how to import with roxygen packages the pipe operator %>% from dplyr

查看:71
本文介绍了如何使用roxygen包导入dplyr中的管道运算符%&%;%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用我编写的一些功能构建一个软件包.现在我的问题是,我无法在dplyr中使用管道操作符%>%.我用roxygen2创建包.

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.

如果我在不使用%>%的情况下编写dplyr命令,则一切正常.

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

在代码内:

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

我写道:

说明

LazyData: true
RoxygenNote: 6.0.1
Imports: dplyr 

roxygen2生成:

roxygen2 generates:

NAMESPACE

NAMESPACE

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

推荐答案

通常,您将从magrittr导入管道运算符.

Usually you would import the pipe operator from magrittr.

您可以将文件添加到软件包的R目录中,如下所示:

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

此外,您还必须在包装的描述文件中将magrittr添加到导入中.

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

这篇关于如何使用roxygen包导入dplyr中的管道运算符%&%;%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆