x <- matrix(c(1, 2, 2, 4),
nrow = 2, byrow = TRUE,
dimnames = list(1:2, c("Sex", "Smoker"))
)
print(x)
# Example 1
vech(x)
# If you just want the vectorized form
vech(x, use.Names = FALSE)
# Example 2: If one has NA's
x[1, 2] <- x[2, 1] <- NA
vech(x)
Run the code above in your browser using DataLab