ch.filterGrpByN: A function to filter data based on the number of elements.

View source: R/ch.filterGrpByN.r

ch.filterGrpByNR Documentation

A function to filter data based on the number of elements.

Description

This function filters the data, it can be grouped using a grouping variable. Basically, it removes all the rows that have fewer than lowNthreshold observations. 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.filterGrpByN(data, dataCol, grpCol = NULL, lowNthreshold = 0)

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.

lowNthreshold

An integer above 0 that specifies the minimum number of observations that the condition must have to be kept in the dataset. DEFAULT = 0

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.filterGrpByN (data=myDataFrame, "RT", "overlapRound", lowNthreshold=10)

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