Last data update: 2014.03.03

R: Monotonic Check
monotonicR Documentation

Monotonic Check

Description

This function can check the monoticity of a single vector, matrix, or data.frame that has multiple IDs within the matrix or data.frame.

Usage

monotonic(data, id.col=NULL, y.col=NULL, direction)

Arguments

data

a data.frame or matrix or vector of measurement data

id.col

column where the id's are stored; default is NULL

y.col

column where y values, or measurements are stored; default is NULL

direction

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

Value

If the user enters a vector, the function returns TRUE or FALSE as to where that particular vector is monotonic increasing or not, it returns NA if the vector has missing values. If the user enters a matrix or data frame, the function returns a matrix with 2 columns. The first column as the id. The second column as a 0 for FALSE and 1 for TRUE as to where the data in that particular id is monotonic increasing or not, or NA if the y column has missing values in that particular id.

Author(s)

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

Examples

data(simulated_data)
## Run monotonic
test <- monotonic(simulated_data, 1,3, direction='inc')

## look at the number of ids that are non-monotonic
table(as.logical(test[,2]))

##to ignore NA values
x<-c(1,2,3,5,NA,7,8)
monotonic(na.omit(x), direction='inc')

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/monotonic.Rd_%03d_medium.png", width=480, height=480)
> ### Name: monotonic
> ### Title: Monotonic Check
> ### Aliases: monotonic
> ### Keywords: mono
> 
> ### ** Examples
> 
> data(simulated_data)
> ## Run monotonic
> test <- monotonic(simulated_data, 1,3, direction='inc')
> 
> ## look at the number of ids that are non-monotonic
> table(as.logical(test[,2]))

FALSE  TRUE 
  422    78 
> 
> ##to ignore NA values
> x<-c(1,2,3,5,NA,7,8)
> monotonic(na.omit(x), direction='inc')
[1] TRUE
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>