jir*_*ec2 6 dependencies r package rcurl roxygen2
我正在尝试编写我的第一个R包.包中的函数取决于RCurl包中的getURL()函数.我按照以下教程:http: //r-pkgs.had.co.nz/和 http://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
我安装了RTools,devtools和roxygen2来编写文档和构建软件包.
我的包名是"waterml".在我的包中,我有文件夹R,包含3个文件GetSites.R,GetVariables.R,GetValues.R.每个文件都有一个功能:
#' GetSites
#' @import XML
#' @importFrom RCurl getURL
#' This function gets the table of sites from the WaterML web service
#' @param server The URL of the web service ending with .asmx,
#' for example: http://worldwater.byu.edu/interactive/rushvalley/services/cuahsi_1_1.asmx
#' @keywords waterml
#' @export
#' @examples
#' GetSites("http://worldwater.byu.edu/interactive/rushvalley/services/cuahsi_1_1.asmx")
GetSites <- function(server) {
sites_url <- paste(server, "/GetSitesObject", sep="")
text <- RCurl::getURL(sites_url)
doc <- xmlRoot(xmlTreeParse(text, getDTD=FALSE, useInternalNodes = TRUE))
return(doc)
}
Run Code Online (Sandbox Code Playgroud)
现在,我尝试构建包:
library(devtools)
document()
Run Code Online (Sandbox Code Playgroud)
document()步骤完成且没有错误.现在我跑:
setwd("..")
install("waterml")
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
* installing *source* package 'waterml' ...
** R
** preparing package for lazy loading
Error : object 'function' is not exported by 'namespace:RCurl'
ERROR: lazy loading failed for package 'waterml'
* removing 'C:/Program Files/R/R-3.1.2/library/waterml'
Run Code Online (Sandbox Code Playgroud)
当我检查我的NAMESPACE文件时,它包含一些奇怪的行:
# Generated by roxygen2 (4.0.2.9000): do not edit by hand
export(GetSites)
export(GetValues)
export(GetVariables)
import(RCurl)
import(XML)
importFrom(RCurl,"function")
importFrom(RCurl,This)
importFrom(RCurl,WaterML)
importFrom(RCurl,data)
importFrom(RCurl,from)
importFrom(RCurl,getURL)
importFrom(RCurl,gets)
importFrom(RCurl,of)
importFrom(RCurl,series)
importFrom(RCurl,service)
importFrom(RCurl,sites)
importFrom(RCurl,table)
importFrom(RCurl,the)
importFrom(RCurl,time)
importFrom(RCurl,values)
importFrom(RCurl,variables)
importFrom(RCurl,web)
Run Code Online (Sandbox Code Playgroud)
我认为错误在声明中:
importFrom(RCurl, "function")
Run Code Online (Sandbox Code Playgroud)
任何想法可能是什么问题?我是否在我的函数文档中正确使用了@importFrom?
更改:
#' GetSites
#' @import XML
#' @importFrom RCurl getURL
#' This function gets the table of sites from the WaterML web service
#' @param server The URL of the web service ending with .asmx,
Run Code Online (Sandbox Code Playgroud)
至:
#' GetSites
#'
#' This function gets the table of sites from the WaterML web service
#'
#' @import XML
#' @importFrom RCurl getURL
#' @param server The URL of the web service ending with .asmx,
Run Code Online (Sandbox Code Playgroud)
roxygen2正在阅读以下行@importFrom并假设每个单词都是您要导入的函数.
| 归档时间: |
|
| 查看次数: |
948 次 |
| 最近记录: |