2017-10-07 121 views
0

我想创建一个包。我使用ggplot2库作为其中一个功能。导入不导入r包开发

我已经写了import语句功能:在DESCRIPTION

#' @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如下

Package: MyPackage 
Title: What the Package Does (one line, title case) 
Version: 0.0.0.9000 
[email protected]: person("Sebastian", "Zeki", email = "[email protected]", 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 

有什么我错过了?

回答

1

这是devtools的开发版本中的一项功能。 您需要从github安装以前的安装:devtools::install_github("hadley/devtools")

Pkg加载机制已移至pkgload。你可以在那里找到这个功能。 Pkgloaddevtools加载所以你不需要打扰。

此答案的答案:
已由rstudio团队成员提问并回答了RStudio community forum