mk_cov_rv: Make Covariate (and their powers) a RV

Description Usage Arguments Details Value Functions Examples

View source: R/mk_cov_rv.R

Description

Get the mean and SD of a covariate

Usage

1
2
3
mk_cov_rv(X, cName, across, by)

mk_cov_rv_pow(X, cName, across, by, pow = 2)

Arguments

X

data.table

cName

name of covariate

across

RV is computed across this dimension

by

RV is computed separately for each of these dimensions

pow

Raise to this power. Default is 2.

Details

Adds columns for the covarate, it's power, and both their sd's. Columns for SD's are named by appending "_sd", column for power is named by appending the numeric value of pow.

Value

NULL is retured, but the data.table is modified, with appropriate columns. Original covariate column will be modified.

Functions

Examples

1
2
3
X <- data.table(a=rnorm(1000), b=sample(letters, 1000, replace=TRUE), key="b")
X[,K:=seq_along(a),by="b"]
mk_cov_rv_pow(X, "a", across="K", by="b", pow=2)

rBatt/trawlDiversity documentation built on Aug. 14, 2021, 1:01 p.m.