Skip to contents

cutoffvalue is a simple R package that implements an updated version of the method first developed and used in Medeiros et al. (2018)1. It can be used to determine an objective cutoff value between a significantly bimodal distribution of log-transformed data and plot a representative graph of the results.

The overall goals of this package are to (1) determine a cutoff value between the upper and lower modes of the dataset and (2) produce a nice graph of the results that includes a histogram of the data, the two models fit to the upper and lower modes, and a line depicting the cutoff value. The functions are written to be run independently, so that only two functions need to be run to get the necessary information:

  • modes() <- Determines modality of the dataset, which is an assumption for the remaining functions
  • cutoffplot() <- Determines the cutoff value and produces a nice graph of the results

The functions in this package are written to utilize the example data set (an internal dataset object identified as “exampledata”) and will use it by default if a dataset is not provided. Below are the instructions on how to install the cutoffvalue package, setup the R Studio environment, and suggestions on how to import and convert your dataset into the proper format. Please see the vignette for more information about each function.

Installation

You can install the development version of cutoffvalue from GitHub with:

# devtools::install_github("lea-medeiros/cutoffvalue", dependencies = TRUE, build_vignettes = TRUE)

Setup RStudio

Load the packages that you will need.

library(cutoffvalue)
library(readxl) # Only necessary if you will be importing an excel file (see below)

Import your dataset

Import the data file to be used in the analyses and graph. The package includes a dataset for use as an example - this object is accessible as “cutoffvalue:::exampledata” and will be used in the examples.

Import your own dataset any way you prefer. I find that the easiest way to import data is to use the “Import Dataset” function built into R Studio, but you can also use code (an example is provided below). The imported data must then be converted into a list of numeric values.

# yourrawdata <- read_excel("/path/to/your/excel/data", col_names = TRUE) # Imports the data as a dataframe with first row as column names
# yourrawdata <- as.numeric(yourrawdata$columnname) # converts the specified column to a numeric list of values

Each function in this package uses the provided dataset (whether it’s the example dataset or one you provided) and cleans it up (via the cleandata function, see the vignette for more information) to remove any blank cells. This function then provides a list of objects: the data (mydata$data), the maximum value (mydata$upper), and the minimum value (mydata$lower), all of which are then used in subsequent calculations.