blk.isConstant: Check Whether a Variable is Constant or Varying Withing...

View source: R/PCSmisc.R

blk.isConstantR Documentation

Check Whether a Variable is Constant or Varying Withing Blocks

Description

This function checks whether a variable is constant or varying withing blocks of a block-format data set. A variable is constant if it takes the same value at each position within a block. It is varying if it takes more than one distinct value within a block.

Usage

blk.isConstant(x, id, ind = NULL)
blk.isVarying(x, id, ind = NULL)

Arguments

x

A vector in block-format with respect to id.

id

A valid block-format ID.

ind

A vector of logicals used to filter the values of x.

Value

A logical.

Author(s)

Benjamin Rich <mail@benjaminrich.net>

See Also

  • block-format

  • blk.applyNto1

  • nunique

Examples

require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,]  # First 4 subjects
attach(dat)

blk.isConstant(Wt,    asID(Subject))     # TRUE
blk.isConstant(Apgar, asID(Subject))     # TRUE
blk.isConstant(dose,  asID(Subject))     # FALSE
blk.isConstant(dose,  asID(Subject), ind=(!is.na(dose) & time > 0))   # TRUE

detach(dat)


benjaminrich/PCSmisc documentation built on Feb. 11, 2024, 9:25 p.m.