MakeCovMat(x, data)
formula
.x
argument can be of class character
, numeric
or formula
as long as the elements described correspond to the column names in the data
data frame.
The data frame specified in argument data
needs to explicitly differentiate between categorical and numerical variables. The elements in the column of a categorical variable must be coerced to be factors
.basta
## Simulated sex and weight data for 5 individuals:
sex <- sample(c("f", "m"), 5, replace = TRUE)
weight <- rnorm(5, mean = 10, sd = 1)
raw.mat <- data.frame(sex, weight)
new.mat <- MakeCovMat(~sex + weight, data = raw.mat)
Run the code above in your browser using DataLab