CMData {CorrBin}R Documentation

Create a ‘CMdata’ object from a data frame.

Description

The CMData function creates an object of class CMData that is used in further analyses. It identifies the variables that define treatment group, clustersize and the number of responses for each outcome type.

Usage

CMData(x, trt, nresp, clustersize = NULL, freq = NULL)

Arguments

x

a data frame with one row representing a cluster or potentially a set of clusters of the same size and number of responses for each outcome

trt

the name of the variable that defines treatment group

nresp

either a character vector with the names or a numeric vector with indices of the variables that define the number of responses in the cluster for each outcome type. If clustersize is NULL, then it will be calculated assuming that the nresp vector contains all the possible outcomes. If clustersize is given, then an additional category is created for the excess cluster members.

clustersize

the name or index of the variable that defines cluster size, or NULL. If NULL, its value will be calculated by adding the counts from the nresp variables. If defined, an additional response type will be created for the excess cluster members.

freq

the name or index of the variable that defines the number of clusters represented by the data row. If NULL, then each row is assumed to correspond to one cluster.

Value

A data frame with each row representing all the clusters with the same trt/size/number of responses, and standardized variable names:

Trt

factor, the treatment group

ClusterSize

numeric, the cluster size

NResp.1--NResp.K+1

numeric, the number of responses for each of the K+1 outcome types

Freq

numeric, number of clusters with the same values

Author(s)

Aniko Szabo

See Also

read.CMData for creating a CMData object directly from a file.

Examples


data(dehp)
dehp <- CMData(dehp, trt="Trt", nresp=c("NResp.1","NResp.2","NResp.3"))
str(dehp)


[Package CorrBin version 1.6.1 Index]