Skip to content

Commit

Permalink
Merge pull request #33 from jread-usgs/master
Browse files Browse the repository at this point in the history
updates for v0.3.1
  • Loading branch information
Jordan S Read committed Oct 20, 2015
2 parents 4d46554 + 58e0159 commit 275c17e
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 20 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: sensorQC
Type: Package
Title: sensorQC
Version: 0.3.0
Date: 2014-08-26
Version: 0.3.1
Date: 2015-10-20
Author: Jordan S Read, Brad Garner, Brian Pellerin
Maintainer: Jordan S Read <jread@usgs.gov>
Description: tools for QAQCing water quality sensor data.
Expand Down
3 changes: 3 additions & 0 deletions R/01-on_load.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.onAttach <- function(libname, pkgname) {
packageStartupMessage("This information is preliminary or provisional and is subject to revision. It is being provided to meet the need for timely best science. The information has not received final approval by the U.S. Geological Survey (USGS) and is provided on the condition that neither the USGS nor the U.S. Government shall be held liable for any damages resulting from the authorized or unauthorized use of the information. Although this software program has been used by the USGS, no warranty, expressed or implied, is made by the USGS or the U.S. Government as to the accuracy and functioning of the program and related program material nor shall the fact of distribution constitute any such warranty, and no responsibility is assumed by the USGS in connection therewith.")
}
9 changes: 7 additions & 2 deletions R/custom-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ MAD.values <- function(vals, b = 1.4826){

MAD.windowed <- function(vals, windows){
stopifnot(length(vals) == length(windows))

. <- '_dplyr_var'
mad <- group_by_(data.frame(x=vals,w=windows), 'w') %>% mutate_(mad='sensorQC:::MAD.values(x)') %>% .$mad
return(mad)
}
Expand All @@ -25,7 +25,7 @@ MAD.windowed <- function(vals, windows){
#'@aliases MAD
#'@aliases median.absolute.deviation
#'@param x values
#'@param windows vector of equal length to x specifying windows
#'@param w vector of equal length to x specifying windows
#'@return a vector of MAD normalized values relative to an undefined rejection criteria (usually 2.5 or 3).
#'@keywords MAD
#'@importFrom dplyr group_by_ mutate_ %>%
Expand All @@ -41,6 +41,11 @@ MAD <- function(x, w){

}

#' function for checking persistent values
#'
#' repeated values of a vector
#' @param x a numeric vector
#' @return a vector that provides a count of persistance
#' @export
persist <- function(x){
tmp <- rle(x)
Expand Down
6 changes: 4 additions & 2 deletions R/flag.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ flag <- function(x, flag.defs, ...){
UseMethod('flag')
}


#' @export
flag.data.frame <- function(x, flag.defs, ...){
UseMethod('flag',sensor(x, flag.defs, ...))
flag.data.frame = function(x, flag.defs, ...){
x = sensor(x)
UseMethod('flag', x)
}

#' @export
Expand Down
19 changes: 10 additions & 9 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#'
#' read from file and create sensor or qconfig object
#'
#' @param file filename
#' @param \dots additional arguments passed to file read methods
#' @param format format for file
#' @param date.format data format of file
#' @rdname read
#' @aliases
#' read
#' read.default
#'
#' @examples
#' qconfig = read(system.file('extdata','pedro.yml', package = 'sensorQC'))
Expand Down Expand Up @@ -47,13 +48,13 @@ read.config <- function(file, ...){

return(as.qconfig(sqc))
}
#' @aliases
#' read
#' read.default
#' @examples
#' file <- system.file('extdata', 'test_data.txt', package = 'sensorQC')
#' data_out <- read(file, format="wide_burst", date.format="%m/%d/%Y %H:%M")

#' read default method
#'
#' read in sensor data
#'
#' @rdname read
#'
#' @export
read.default <- function(file, format, date.format, ...){

Expand Down
7 changes: 7 additions & 0 deletions R/sensor-class.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#' create a sensor object
#'
#' sensor data
#'
#' @param x a data.frame or sensor object
#' @param flag.defs definitions for flags. Functions that can be evaluated to T/F
#' @param \dots additional flag.defs
#' @export
sensor <- function(x, flag.defs, ...){
UseMethod('sensor')
Expand Down
3 changes: 2 additions & 1 deletion R/window.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @description
#' Breaks up time series data into window chunks. \cr
#' @param x a data.frame of time series data
#' @param \dots not used
#' @param type numeric, in seconds, specifying the window time width. or
#' "auto" to automatically window data
#' @return a list of time series data and indices for breaks
Expand All @@ -13,7 +14,7 @@
#' @author
#' Jordan S. Read
#' @export
window.sensor<- function(x, type){
window.sensor<- function(x, ..., type){

# breaks up data into time-windowed chunks
# returns a list of breaks
Expand Down
2 changes: 1 addition & 1 deletion man/MAD.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MAD(x, w)
\arguments{
\item{x}{values}

\item{windows}{vector of equal length to x specifying windows}
\item{w}{vector of equal length to x specifying windows}
}
\value{
a vector of MAD normalized values relative to an undefined rejection criteria (usually 2.5 or 3).
Expand Down
18 changes: 18 additions & 0 deletions man/persist.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/custom-functions.R
\name{persist}
\alias{persist}
\title{function for checking persistent values}
\usage{
persist(x)
}
\arguments{
\item{x}{a numeric vector}
}
\value{
a vector that provides a count of persistance
}
\description{
repeated values of a vector
}

13 changes: 11 additions & 2 deletions man/read.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ read(file, ...)

read.default(file, format, date.format, ...)
}
\arguments{
\item{file}{filename}

\item{format}{format for file}

\item{date.format}{data format of file}

\item{\dots}{additional arguments passed to file read methods}
}
\description{
read from file and create sensor or qconfig object

read in sensor data
}
\examples{
qconfig = read(system.file('extdata','pedro.yml', package = 'sensorQC'))
file <- system.file('extdata', 'test_data.txt', package = 'sensorQC')
data_out <- read(file, format="wide_burst", date.format="\%m/\%d/\%Y \%H:\%M")
}

19 changes: 19 additions & 0 deletions man/sensor.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/sensor-class.R
\name{sensor}
\alias{sensor}
\title{create a sensor object}
\usage{
sensor(x, flag.defs, ...)
}
\arguments{
\item{x}{a data.frame or sensor object}

\item{flag.defs}{definitions for flags. Functions that can be evaluated to T/F}

\item{\dots}{additional flag.defs}
}
\description{
sensor data
}

4 changes: 3 additions & 1 deletion man/window.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
\alias{window.sensor}
\title{window sensorQC data}
\usage{
\method{window}{sensor}(x, type)
\method{window}{sensor}(x, ..., type)
}
\arguments{
\item{x}{a data.frame of time series data}

\item{type}{numeric, in seconds, specifying the window time width. or
"auto" to automatically window data}

\item{\dots}{not used}
}
\value{
a list of time series data and indices for breaks
Expand Down

0 comments on commit 275c17e

Please sign in to comment.