Learn R Programming

rmutil (version 1.1.10)

tcctomat: Create a Time-constant, Inter-individual Covariate (tccov) Object

Description

tcctomat creates an object of class, tccov, from a vector or matrix containing time-constant or inter-individual baseline covariates or a model formula. It can also combine two such objects.

Such objects can be printed. Methods are available for extracting the covariates, their names, and the formula: covariates, names, and formula. The method, transform, can transform variables in place or by adding new variables to the object.

To obtain the indexing to expand time-constant or inter-individual covariates to the size of a repeated measurements response, use covind.

Usage

tcctomat(ccov, names=NULL, units=NULL, oldccov=NULL, dataframe=TRUE,
	description=NULL)

Value

Returns an object of class, tccov, containing one matrix or dataframe for the covariates (z$ccov) with one row per individual and possibly the model formula (z$linear).

Arguments

ccov

A vector, matrix, or dataframe containing time-constant or inter-individual baseline covariates with one row per individual, a model formula using vectors of the same size, or an object of class, tccov. In the first two cases, the variables may be factors; if dataframe=FALSE, these are transformed to indicator variables.

units

Optional character vector specifying units of measurements of covariates.

names

The names of the covariates (if the matrix does not have column names).

oldccov

An object of class, tccov, to which ccov is to be added.

dataframe

If TRUE and factor variables are present, the covariates are stored as a dataframe; if FALSE, they are expanded to indicator variables. If no factor variables are present, covariates are always stored as a matrix.

description

An optional named list of character vectors with names of some or all covariates containing their descriptions.

Author

J.K. Lindsey

See Also

DataMethods, covariates, description, formula, lvna, names, restovec, rmna, transform, tvctomat, units

Examples

Run this code
x1 <- gl(4,1)
print(tcc1 <- tcctomat(~x1))
covariates(tcc1)
covariates(tcc1, name="x12")
tcctomat(x1)
tcctomat(x1, dataframe=FALSE)
x2 <- c(0,0,1,1)
print(tcc2 <- tcctomat(~x2, units="days"))
covariates(tcc2)
print(tcc3 <- tcctomat(~x1+x2))
covariates(tcc3)
covariates(tcc3, names=c("x12","x2"))
formula(tcc3)
names(tcc3)
print(tcc4 <- tcctomat(data.frame(x1,x2), units=c(NA,"days")))
covariates(tcc4)
print(tcc5 <- tcctomat(data.frame(x1,x2), dataframe=FALSE, units=c(NA,"days")))
covariates(tcc5)

Run the code above in your browser using DataLab