ch.filterGrpByQuantile: A function to filter data based on the quantile value.

View source: R/ch.filterGrpByQuantile.r

ch.filterGrpByQuantileR Documentation

A function to filter data based on the quantile value.

Description

This function filters the data, it can be grouped using a grouping variable, between a low quantile threshold and/or a high quantile threshold. It returns a list that contains a dataframe of the removed data, a dataframe of the the kept data, the number of datapoints removed, and the percentage of points removed.

Usage

ch.filterGrpByQuantile(
  data,
  dataCol,
  grpCol = NULL,
  lowQuantileThreshold = 0,
  highQuantileThreshold = 1
)

Arguments

data

a dataframe containing the data.

dataCol

a string that specifies the name of the column in "data" on which the thresholds are to act.

grpCol

a string or vector of strings that specify the names of the column in "data" that act as grouping variables.

lowQuantileThreshold

A decimal between 0 and 1 that specifies the low quantile threshold, that the data must be above to be kept.

highQuantileThreshold

A decimal between 0 and 1 that specifies the high quantile threshold, that the data must be below to be kept.

Value

a list containing: (datRemoved) a dataframe with the removed data as grouped by grpCol; (datKept) a dataframe with the kept data as grouped by grpCol; (numRemoved) the number of datapoints removed; (pRemoved) the proportion of datapoints removed; (datKeptRaw) a dataframe with the kept data in the raw format (ungrouped);.

Examples

ch.filterGrpByQuantile (data=myDataFrame, "RT", "sn", lowQuantileThreshold=0.05, highQuantileThreshold=0.95)

ccpluncw/ccpl_R_chutils documentation built on Feb. 28, 2024, 1:17 a.m.