Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dataRetrieval
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water
dataRetrieval
Commits
53b55854
Commit
53b55854
authored
10 years ago
by
Laura A DeCicco
Browse files
Options
Downloads
Patches
Plain Diff
Added ability to use either pcode or characteristicName.
parent
9cd25312
No related branches found
No related tags found
1 merge request
!2
Updating naming convention + other minor changes.
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/processQWData.r
+12
-4
12 additions, 4 deletions
R/processQWData.r
with
12 additions
and
4 deletions
R/processQWData.r
+
12
−
4
View file @
53b55854
...
...
@@ -4,7 +4,8 @@
#' 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.
#'
#' @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
#' @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)
...
...
@@ -13,7 +14,7 @@
#' # These examples require an internet connection to run
#' rawSample <- getRawQWData('01594440','01075', '1985-01-01', '1985-03-31')
#' rawSampleSelect <- processQWData(rawSample)
processQWData
<-
function
(
data
){
processQWData
<-
function
(
data
,
pCode
=
TRUE
){
qualifier
<-
ifelse
((
data
$
ResultDetectionConditionText
==
"Not Detected"
|
data
$
ResultDetectionConditionText
==
"Detected Not Quantified"
|
...
...
@@ -37,8 +38,15 @@ processQWData <- function(data){
warning
(
warningMessage
)
}
colnames
(
test
)
<-
c
(
"USGSPCode"
,
"dateTime"
,
"qualifier"
,
"value"
)
data
<-
suppressWarnings
(
reshape
(
test
,
idvar
=
"dateTime"
,
timevar
=
"USGSPCode"
,
direction
=
"wide"
))
if
(
pCode
){
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
<-
as.Date
(
data
$
dateTime
)
return
(
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment