Last data update: 2014.03.03

R: Flag
mono.flagR Documentation

Flag

Description

This function flags data that is outside the prespecified range and that is not monotonic.

Usage

mono.flag(data, id.col, x.col, y.col, min, max, data.r = NULL, tol = 0, direction)

Arguments

data

a data.frame or matrix of measurement data

id.col

column where the id's are stored

x.col

column where x values, or time variable is stored

y.col

column where y values, or measurements are stored

min

lowest acceptable value for measurement; does not have to be a number in ycol

max

highest acceptable value for measurement; does not have to be a number in ycol

data.r

prespecified range for y values; must have three columns: 1 - must match values in xcol, 2 - lower range values, 3 - upper range values

tol

tolerance; how much outside of the range (data.r) is acceptable; same units as data in ycol

direction

the direction of the function a choice between increasing 'inc', and decreasing 'dec'

Details

The data range (data.r) does not need to have the same number of rows as data; it only needs to include the exact time increments as xcol.

Value

Returns the data matrix with two additional columns. "Decreasing" is a logical vector that is TRUE if the observation decreases, or causes the ID to be non-monotonic. "Outside.Range" is a logical vector that returns TRUE if the observation is outside of the data.r +/- tol range. Any duplicate rows are removed.

Author(s)

Michele Josey mjosey@nccu.edu Melyssa Minto mminto@nccu.edu

Examples

data(simulated_data)
simulated_data <- simulated_data[1:1000,]
data(data.r)
## run mono.flag function 
test <- mono.flag(simulated_data, 1, 2, 3, 30, 175, data.r=data.r, direction='inc')
head(test)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MonoInc)
Loading required package: compare

Attaching package: 'compare'

The following object is masked from 'package:base':

    isTRUE

Loading required package: doParallel
Loading required package: foreach
Loading required package: iterators
Loading required package: parallel
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MonoInc/mono.flag.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mono.flag
> ### Title: Flag
> ### Aliases: mono.flag
> ### Keywords: flag
> 
> ### ** Examples
> 
> data(simulated_data)
> simulated_data <- simulated_data[1:1000,]
> data(data.r)
> ## run mono.flag function 
> test <- mono.flag(simulated_data, 1, 2, 3, 30, 175, data.r=data.r, direction='inc')
Warning message:
executing %dopar% sequentially: no parallel backend registered 
> head(test)
  ID  X         Y Decreasing Outside.Range
1  1 13  66.94740      FALSE          TRUE
2  1 27  82.41612      FALSE         FALSE
3  1 42  98.21975      FALSE         FALSE
4  1 44  95.80379       TRUE         FALSE
5  1 46 100.33827      FALSE         FALSE
6  1 58 106.61578      FALSE         FALSE
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>