diff --git a/DESCRIPTION b/DESCRIPTION index 508bbdd..3bb8ea0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 Description: tools for QAQCing water quality sensor data. diff --git a/R/01-on_load.R b/R/01-on_load.R new file mode 100644 index 0000000..8fe2799 --- /dev/null +++ b/R/01-on_load.R @@ -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.") +} \ No newline at end of file diff --git a/R/custom-functions.R b/R/custom-functions.R index 5fbb97c..ef5cf75 100644 --- a/R/custom-functions.R +++ b/R/custom-functions.R @@ -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) } @@ -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_ %>% @@ -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) diff --git a/R/flag.R b/R/flag.R index c22f3a8..8301716 100644 --- a/R/flag.R +++ b/R/flag.R @@ -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 diff --git a/R/read.R b/R/read.R index 2aefb14..ea8d430 100644 --- a/R/read.R +++ b/R/read.R @@ -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')) @@ -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, ...){ diff --git a/R/sensor-class.R b/R/sensor-class.R index 350a550..599f087 100644 --- a/R/sensor-class.R +++ b/R/sensor-class.R @@ -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') diff --git a/R/window.R b/R/window.R index 807c319..a7fabb7 100644 --- a/R/window.R +++ b/R/window.R @@ -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 @@ -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 diff --git a/man/MAD.Rd b/man/MAD.Rd index 393d6cc..fc71ec2 100644 --- a/man/MAD.Rd +++ b/man/MAD.Rd @@ -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). diff --git a/man/persist.Rd b/man/persist.Rd new file mode 100644 index 0000000..67b2f41 --- /dev/null +++ b/man/persist.Rd @@ -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 +} + diff --git a/man/read.Rd b/man/read.Rd index 59e36df..0ac4d37 100644 --- a/man/read.Rd +++ b/man/read.Rd @@ -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") } diff --git a/man/sensor.Rd b/man/sensor.Rd new file mode 100644 index 0000000..a1d5f0e --- /dev/null +++ b/man/sensor.Rd @@ -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 +} + diff --git a/man/window.Rd b/man/window.Rd index f2691fd..07a11bd 100644 --- a/man/window.Rd +++ b/man/window.Rd @@ -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