Commit 83dc1c6b authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Merge pull request #178 from ldecicco-USGS/master

Remove plyr dependency
parents bb116e3e 38f8657d
......@@ -10,7 +10,9 @@ Authors@R: c( person("Robert", "Hirsch", role = c("aut"),
person("David","Lorenz", role=c("aut"),
email = "lorenz@usgs.gov"),
person("Jordan", "Read", role = c("ctb"),
email = "jread@usgs.gov"))
email = "jread@usgs.gov"),
person("Lindsay","Carr", role=c("ctb"),
email = "lcarr@usgs.gov"))
Description: Collection of functions to help retrieve U.S. Geological Survey
(USGS) and U.S. Environmental Protection Agency (EPA) water quality and
hydrology data from web services. USGS web services are discovered from the
......@@ -29,7 +31,6 @@ Imports:
RCurl,
reshape2,
lubridate,
plyr,
stats,
utils,
dplyr,
......
......@@ -52,10 +52,10 @@ importFrom(XML,xpathSApply)
importFrom(dplyr,left_join)
importFrom(dplyr,mutate_)
importFrom(dplyr,mutate_each_)
importFrom(dplyr,rbind_all)
importFrom(dplyr,select_)
importFrom(lubridate,fast_strptime)
importFrom(lubridate,parse_date_time)
importFrom(plyr,rbind.fill.matrix)
importFrom(readr,col_character)
importFrom(readr,col_number)
importFrom(readr,cols)
......
pkg.env <- new.env()
.onLoad = function(libname, pkgname){
suppressMessages(setAccess('public'))
options(Access.dataRetrieval = NULL)
}
\ No newline at end of file
......@@ -133,7 +133,6 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
timeSeries <- xpathApply(doc, "//ns1:timeSeries", namespaces = ns)
if(0 == length(timeSeries)){
df <- data.frame()
attr(df, "queryInfo") <- queryInfo
......@@ -287,16 +286,7 @@ importWaterML1 <- function(obs_url,asDateTime=FALSE, tz=""){
datetime <- datetime - tzHours*60*60
}
}
# if(tz != ""){
# attr(datetime, "tzone") <- tz
# df$tz_cd <- rep(tz, nrow(df))
# } else {
# attr(datetime, "tzone") <- "UTC"
# df$tz_cd <- rep("UTC", nrow(df))
# }
} else {
datetime <- as.character(datetime)
......
......@@ -19,7 +19,7 @@
#' @importFrom XML xmlValue
#' @importFrom XML xmlAttrs
#' @importFrom XML xmlName
#' @importFrom plyr rbind.fill.matrix
#' @importFrom dplyr rbind_all
#' @examples
#' baseURL <- "http://waterservices.usgs.gov/nwis/dv/?format=waterml,2.0"
#' URL <- paste(baseURL, "sites=01646500",
......@@ -83,16 +83,7 @@ importWaterML2 <- function(obs_url, asDateTime=FALSE, tz=""){
chunk <- xmlDoc(timeSeries[[i]])
chunk <- xmlRoot(chunk)
chunkNS <- xmlNamespaceDefinitions(chunk, simplify = TRUE)
# xp <- xpathApply(chunk, "//wml2:MeasurementTimeseries/wml2:point/wml2:MeasurementTVP",
# xpathSApply, ".//*[not(*)]",
# function(x) setNames(ifelse(nzchar(xmlValue(x)),
# xmlValue(x),
# ifelse("qualifier" == xmlName(x),
# xpathSApply(x,"./@xlink:title",namespaces = ns),"")), #originally I had the "" as xmlAttr(x)
# xmlName(x)),
# namespaces = chunkNS)
xp <- xpathApply(chunk, "//wml2:MeasurementTimeseries/wml2:point/wml2:MeasurementTVP",
xpathSApply, ".//*[not(*)]",
function(x) setNames(ifelse(nzchar(xmlValue(x)),
......@@ -108,9 +99,9 @@ importWaterML2 <- function(obs_url, asDateTime=FALSE, tz=""){
xp <- xp[-1]
}
DF2 <- do.call(rbind.fill.matrix, lapply(xp, t))
DF2 <- as.data.frame(DF2,stringsAsFactors=FALSE)
y <- lapply(xp,t)
z <- lapply(y, as.data.frame)
DF2 <- suppressWarnings(rbind_all(z))
names(DF2)[grep("wml2",names(DF2))] <- sub("wml2:","",names(DF2)[grep("wml2",names(DF2))])
......@@ -150,11 +141,7 @@ importWaterML2 <- function(obs_url, asDateTime=FALSE, tz=""){
} else {
DF2$qualifier <- rep(defaultQualifier,nrow(DF2))
}
# DF2$qualifier <- ifelse("Provisional data subject to revision." == DF2$qualifier, "P",
# ifelse("Approved for publication. Processing and review completed." == DF2$qualifier, "A", DF2$qualifier))
#########################################
id <- as.character(xpathApply(chunk, "//gml:identifier", xmlValue, namespaces = chunkNS))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment