I'm trying to write my first R package. The functions in the package depend on the getURL() function from the RCurl package. I followed the tutorials on: http://r-pkgs.had.co.nz/ and http://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
I installed RTools, devtools and roxygen2 for writing the documentation and building the package.
The name of my package is "waterml". In my package I have the folder R with 3 files GetSites.R , GetVariables.R, GetValues.R. Each file has one function:
#' 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)
}
Now, I try to build the package:
library(devtools)
document()
The document() step completes without error. Now I run:
setwd("..")
install("waterml")
But I get the error:
* 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'
When I checked my NAMESPACE file, it contains some strange lines:
# 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)
I think that the error is in the statement:
importFrom(RCurl, "function")
Any ideas what could be the problem? Am I using the @importFrom in the documentation of my function correctly?
@importFrom RCUrl getURL
since the OP is doingRCurl::getURL()
– Pasteurizer