Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导入不';r封装开发中的t导入_R_R Package - Fatal编程技术网

导入不';r封装开发中的t导入

导入不';r封装开发中的t导入,r,r-package,R,R Package,我正在尝试创建一个包。我对其中一个函数使用了ggplot2库 我已经为函数编写了导入语句: #' @param x the dataframe #' @param Column the dataframe #' @param Code the dataframe #' @keywords Appointment filtering #' @import ggplot2 #' @importFrom magrittr '%>%' #' @importFrom dplyr arrange gr

我正在尝试创建一个包。我对其中一个函数使用了
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
并在
说明中写入
导入:ggplot2
,如下所示

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" 
我注意到
名称空间
文件不包含ggplot,但存在其他导入,但当我手动添加到
名称空间
时,我会收到一个错误,显示:

Error in importIntoEnv(pkgenv, exports, nsenv, exports) : 
  cannot add bindings to a locked environment

我错过了什么?

这是devel版本的
devtools
中的一项功能。 您需要从以前安装的github安装它:
devtools::install\u github(“hadley/devtools”)

Pkg加载机制已移至
pkgload
。您可以在那里找到此功能
Pkgload
是由
devtools
加载的,因此您无需费心

此答案的来源:
一位rstudio团队成员已在中询问并回答了此问题