【发布时间】:2017-10-07 13:11:44
【问题描述】:
我正在尝试创建一个包。我将ggplot2 库用于其中一个功能。
我已经为函数编写了导入语句:
#' @param x the dataframe
#' @param Column the dataframe
#' @param Code the dataframe
#' @keywords Appointment filtering
#' @import ggplot2
#' @importFrom magrittr '%>%'
#' @importFrom dplyr arrange group_by summarise
#' @import rlang
#' @export
并将Imports:ggplot2 写在DESCRIPTION 中,如下所示
Package: MyPackage
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("Sebastian", "Zeki", email = "first.last@example.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends: R (>= 3.4.0)
Imports:
ggplot2
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
每当我从 devtools 运行 load_all() 或 document() 时,我都会收到错误消息:
Error in ggplot(....) :
could not find function "ggplot"
我注意到 NAMESPACE 文件不包含 ggplot 但确实存在其他导入,但是当我手动添加到 NAMESPACE 时,我收到一条错误消息:
Error in importIntoEnv(pkgenv, exports, nsenv, exports) :
cannot add bindings to a locked environment
我错过了什么?
【问题讨论】: