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
b79e12d4
Commit
b79e12d4
authored
12 years ago
by
Laura A DeCicco
Browse files
Options
Downloads
Patches
Plain Diff
Added a logical argument to decide whether or not to convert from cfs to cms.
parent
c5957453
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/getDVData.r
+6
-2
6 additions, 2 deletions
R/getDVData.r
R/retrieveNWISData.r
+4
-4
4 additions, 4 deletions
R/retrieveNWISData.r
with
10 additions
and
6 deletions
R/getDVData.r
+
6
−
2
View file @
b79e12d4
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#' @param StartDate string starting date for data retrieval in the form YYYY-MM-DD.
#' @param StartDate string starting date for data retrieval in the form YYYY-MM-DD.
#' @param EndDate string ending date for data retrieval in the form YYYY-MM-DD.
#' @param EndDate string ending date for data retrieval in the form YYYY-MM-DD.
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @param interactive logical Option for interactive mode. If true, there is user interaction for error handling and data checks.
#' @param convert logical Option to include a conversion from cfs to cms (35.314667). The default is TRUE,
#' which is appropriate for using NWIS data in the EGRET package. Set this to FALSE to not include the conversion.
#' @keywords data import USGS WRTDS
#' @keywords data import USGS WRTDS
#' @export
#' @export
#' @return Daily dataframe
#' @return Daily dataframe
...
@@ -16,10 +18,12 @@
...
@@ -16,10 +18,12 @@
#' @examples
#' @examples
#' # These examples require an internet connection to run
#' # These examples require an internet connection to run
#' Daily <- getDVData('01594440','00060', '1985-01-01', '1985-03-31', interactive=FALSE)
#' Daily <- getDVData('01594440','00060', '1985-01-01', '1985-03-31', interactive=FALSE)
getDVData
<-
function
(
siteNumber
,
ParameterCd
,
StartDate
,
EndDate
,
interactive
=
TRUE
){
getDVData
<-
function
(
siteNumber
,
ParameterCd
,
StartDate
,
EndDate
,
interactive
=
TRUE
,
convert
=
TRUE
){
data
<-
retrieveNWISData
(
siteNumber
,
ParameterCd
,
StartDate
,
EndDate
,
interactive
=
interactive
)
data
<-
retrieveNWISData
(
siteNumber
,
ParameterCd
,
StartDate
,
EndDate
,
interactive
=
interactive
)
# need to setup conversion factor because the NWIS data are in cfs but we store in cms
# need to setup conversion factor because the NWIS data are in cfs but we store in cms
qConvert
<
-35.314667
names
(
data
)
<-
c
(
'agency'
,
'site'
,
'dateTime'
,
'value'
,
'code'
)
# do a merge instead?
qConvert
<-
ifelse
(
convert
,
35.314667
,
1
)
localDaily
<-
populateDaily
(
data
,
qConvert
,
interactive
=
interactive
)
localDaily
<-
populateDaily
(
data
,
qConvert
,
interactive
=
interactive
)
return
(
localDaily
)
return
(
localDaily
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
R/retrieveNWISData.r
+
4
−
4
View file @
b79e12d4
...
@@ -64,15 +64,15 @@ retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="0
...
@@ -64,15 +64,15 @@ retrieveNWISData <- function (siteNumber,ParameterCd,StartDate,EndDate,StatCd="0
if
(
class
(
ret.val
)
==
"try-error"
)
if
(
class
(
ret.val
)
==
"try-error"
)
ret.val
<-
x
ret.val
<-
x
}
}
else
if
(
regexpr
(
'n$'
,
Typ
)
>
0
)
# Must be numeric...be careful of ice
#
else if(regexpr('n$', Typ) > 0) # Must be numeric...be careful of ice
ret.val
<-
as.numeric
(
x
)
#
ret.val <- as.numeric(x)
else
# Must be character
else
# Must be character
ret.val
<-
x
ret.val
<-
x
return
(
ret.val
)})
return
(
ret.val
)})
retval
<-
as.data.frame
(
retval
,
stringsAsFactors
=
FALSE
)
retval
<-
as.data.frame
(
retval
,
stringsAsFactors
=
FALSE
)
colNames
<-
names
(
retval
)
# colNames <- names(retval)
names
(
retval
)
<-
c
(
'agency'
,
'site'
,
'dateTime'
,
'value'
,
'code'
)
# do a merge instead?
return
(
retval
)
return
(
retval
)
}
}
\ No newline at end of file
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