trim_min_valid_obs: Keep only groups (usually days) with enough non-missing...

Description Usage Arguments Examples

Description

This function allows for trimming esm data down so that only days (or people) with a minimum number of observations are included. If there is a 'missed' variable (coded 1 = missed) these rows will not be counted. Missing values on the specified variables will also not be counted. Essentially, this ensures that there will be at least min.obs number of valid values within each grouping factor retained. For a more general function, see trim_min_obs.

Usage

1
trim_min_valid_obs(data, grouping, variables, min.obs = 2)

Arguments

data

The input dataset

grouping

The grouping variables within which you require a minimum observation number. Could be just your person id or your person id and day. Should take the form of a character vector.

variables

The variables you require a certain number of values on.

min.obs

The minimum number of observations to require. Defaults to 2.

Examples

1
2
# Trim the sleep dataset to have 2 obs per ID (this does nothing, but illustrates syntax)
trim_min_valid_obs(sleep, grouping = 'ID', variables = 'extra', min.obs = 2)

seanchrismurphy/emacalc documentation built on May 12, 2019, 2:03 p.m.