ch.filterGrpBtwn: A function to filter data between two thresholds grouped by a...

View source: R/ch.filterDataBetween.r

ch.filterGrpBtwnR Documentation

A function to filter data between two thresholds grouped by a single column

Description

This function filters the data, based on a grouping variable, between a low threshold and/or a high 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.filterGrpBtwn(
  data,
  dataCol,
  grpCol,
  lowThresh = NULL,
  highThresh = NULL,
  FUN
)

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 that specifies the name of the column in "data" that acts as a grouping variable.

lowThresh

the lower threshold that the data must be above to be kept.

highThresh

the higher threshold that the data must be below to be kept.

FUN

the function that specifies the how to combine dataCol by grpCol (e.g., mean).

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.filterGrpBtwn (data=myDataFrame, "RT", "sn", 200, 5000, mean)

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