Skip to content

Commit

Permalink
added feature to setstep for chr input with timestep argument
Browse files Browse the repository at this point in the history
  • Loading branch information
fawda123 committed Apr 12, 2015
1 parent 4ee4075 commit ce3d6bf
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
^\.Rhistory$
^appveyor\.yml$
^cran-comments\.md$
^swmpr_logo.png
^swmpr_logo.png$
^Thumbs.db$
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: SWMPr
Type: Package
Title: Retrieving, Organizing, and Analyzing Estuary Monitoring Data
Version: 2.0.0
Date: 2015-4-1
Version: 2.0.1
Date: 2015-4-12
Author: Marcus W. Beck [aut, cre]
Maintainer: Marcus W. Beck <[email protected]>
Description: Tools for retrieving, organizing, and analyzing environmental
Expand Down
26 changes: 24 additions & 2 deletions R/swmpr_organize.R
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ subset.swmpr <- function(x, subset = NULL, select = NULL,
#' Create a continuous time vector at set time step for a swmpr object
#'
#' @param swmpr_in input swmpr object
#' @param timestep numeric value of time step to use in minutes
#' @param timestep numeric value of time step to use in minutes. Alternatively, a chr string indicating \code{'years'}, \code{'quarters'}, \code{'months'}, \code{'days'}, or \code{'hours'} can also be used. A character input assumes 365 days in a year and 31 days in a month.
#' @param differ numeric value defining buffer for merging time stamps to standardized time series
#' @param ... arguments passed to or from other methods
#'
Expand Down Expand Up @@ -489,10 +489,32 @@ setstep.swmpr <- function(swmpr_in, timestep = 15, differ= timestep/2, ...){
# swmpr data and attributes
dat <- swmpr_in
attrs <- attributes(swmpr_in)

# convert timestep to numeric if chr input
if(is.character(timestep)){

# lookup values
chr_stp <- c('years', 'quarters', 'months', 'weeks', 'days', 'hours')
mul_fac <- c(525600, 131400, 44640, 10080, 1440, 60)

# stop if chr_stp is wrong
if(!timestep %in% chr_stp){

stop(paste(
'Character input for timestep must be one of of the following:',
paste(chr_stp, collapse = ', ')
))

}

# otherwise lookup
timestep <- mul_fac[which(timestep == chr_stp)]

}

# sanity check
if(timestep/2 < differ)
stop('Value for differ must be less than one half of timestep')
stop('Value for differ must be less than or equal to one half of timestep')
if('Date' %in% attrs$stamp_class)
stop('Cannot use setstep with date class')

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Windows: [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/g

The System Wide Monitoring Program ([SWMP](http://nerrs.noaa.gov/RCDefault.aspx?ID=18)) was implemented by the National Estuarine Research Reserve System ([NERRS](http://nerrs.noaa.gov/)) in 1995 to provide continuous monitoring data at over 300 continuous monitoring stations in 28 estuaries across the United States. SWMPr (pronounced "swamper") is an R package for retrieving, organizing, and analyzing estuary monitoring data from SWMP. Please cite the package as follows:

*Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.0. https://github.com/fawda123/SWMPr*
*Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.1. https://github.com/fawda123/SWMPr*

#Installing the package

Expand Down
2 changes: 1 addition & 1 deletion README.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h4><em>Marcus W. Beck, <a href="mailto:[email protected]">[email protected]
<div id="overview" class="section level1">
<h1>Overview</h1>
<p>The System Wide Monitoring Program (<a href="http://nerrs.noaa.gov/RCDefault.aspx?ID=18">SWMP</a>) was implemented by the National Estuarine Research Reserve System (<a href="http://nerrs.noaa.gov/">NERRS</a>) in 1995 to provide continuous monitoring data at over 300 continuous monitoring stations in 28 estuaries across the United States. SWMPr (pronounced “swamper”) is an R package for retrieving, organizing, and analyzing estuary monitoring data from SWMP. Please cite the package as follows:</p>
<p><em>Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.0. <a href="https://github.com/fawda123/SWMPr" class="uri">https://github.com/fawda123/SWMPr</a></em></p>
<p><em>Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.1. <a href="https://github.com/fawda123/SWMPr" class="uri">https://github.com/fawda123/SWMPr</a></em></p>
</div>
<div id="installing-the-package" class="section level1">
<h1>Installing the package</h1>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Windows: [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/g

The System Wide Monitoring Program ([SWMP](http://nerrs.noaa.gov/RCDefault.aspx?ID=18)) was implemented by the National Estuarine Research Reserve System ([NERRS](http://nerrs.noaa.gov/)) in 1995 to provide continuous monitoring data at over 300 continuous monitoring stations in 28 estuaries across the United States. SWMPr (pronounced "swamper") is an R package for retrieving, organizing, and analyzing estuary monitoring data from SWMP. Please cite the package as follows:

*Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.0. https://github.com/fawda123/SWMPr*
*Beck MW. 2015. SWMPr: An R package for the National Estuarine Research Reserve System. Version 2.0.1. https://github.com/fawda123/SWMPr*

#Installing the package

Expand Down
Binary file modified Thumbs.db
Binary file not shown.
2 changes: 1 addition & 1 deletion man/setstep.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setstep(swmpr_in, ...)

\item{...}{arguments passed to or from other methods}

\item{timestep}{numeric value of time step to use in minutes}
\item{timestep}{numeric value of time step to use in minutes. Alternatively, a chr string indicating \code{'years'}, \code{'quarters'}, \code{'months'}, \code{'days'}, or \code{'hours'} can also be used. A character input assumes 365 days in a year and 31 days in a month.}

\item{differ}{numeric value defining buffer for merging time stamps to standardized time series}
}
Expand Down

0 comments on commit ce3d6bf

Please sign in to comment.