Learn R Programming

CorrBin (version 1.4)

CMData: 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 a
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 c
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:
  • Trtfactor, the treatment group
  • ClusterSizenumeric, the cluster size
  • NResp.1--NResp.K+1numeric, the number of responses for each of the K+1 outcome types
  • Freqnumeric, number of clusters with the same values

See Also

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

Examples

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

Run the code above in your browser using DataLab