2017-10-07 122 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