Skip to content
Snippets Groups Projects
Commit 53b55854 authored by Laura A DeCicco's avatar Laura A DeCicco
Browse files

Added ability to use either pcode or characteristicName.

parent 9cd25312
No related branches found
No related tags found
1 merge request!2Updating naming convention + other minor changes.
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#' conditions to determine if a value is left censored or not. Censored values are given the qualifier #' conditions to determine if a value is left censored or not. Censored values are given the qualifier
#' "<". The dataframe is also converted from a long to wide format. #' "<". The dataframe is also converted from a long to wide format.
#' #'
#' @param data dataframe from #' @param data dataframe from Water Quality Portal
#' @param pCode logical if TRUE, assume data came from a pCode search, if FALSE, characteristic name.
#' @keywords data import USGS web service #' @keywords data import USGS web service
#' @return data dataframe with first column dateTime, and at least one qualifier and value columns #' @return data dataframe with first column dateTime, and at least one qualifier and value columns
#' (subsequent qualifier/value columns could follow depending on the number of parameter codes) #' (subsequent qualifier/value columns could follow depending on the number of parameter codes)
...@@ -13,7 +14,7 @@ ...@@ -13,7 +14,7 @@
#' # These examples require an internet connection to run #' # These examples require an internet connection to run
#' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31') #' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- processQWData(rawSample) #' rawSampleSelect <- processQWData(rawSample)
processQWData <- function(data){ processQWData <- function(data,pCode=TRUE){
qualifier <- ifelse((data$ResultDetectionConditionText == "Not Detected" | qualifier <- ifelse((data$ResultDetectionConditionText == "Not Detected" |
data$ResultDetectionConditionText == "Detected Not Quantified" | data$ResultDetectionConditionText == "Detected Not Quantified" |
...@@ -37,8 +38,15 @@ processQWData <- function(data){ ...@@ -37,8 +38,15 @@ processQWData <- function(data){
warning(warningMessage) warning(warningMessage)
} }
colnames(test)<- c("USGSPCode","dateTime","qualifier","value") if (pCode){
data <- suppressWarnings(reshape(test, idvar="dateTime", timevar = "USGSPCode", direction="wide")) colnames(test)<- c("USGSPCode","dateTime","qualifier","value")
newTimeVar <- "USGSPCode"
} else {
colnames(test)<- c("CharacteristicName","dateTime","qualifier","value")
newTimeVar <- "CharacteristicName"
}
data <- suppressWarnings(reshape(test, idvar="dateTime", timevar = newTimeVar, direction="wide"))
data$dateTime <- format(data$dateTime, "%Y-%m-%d") data$dateTime <- format(data$dateTime, "%Y-%m-%d")
data$dateTime <- as.Date(data$dateTime) data$dateTime <- as.Date(data$dateTime)
return(data) return(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment