Closed
Description
I would like report to create traditional correlation matrices from the data provided by the new correlation package, which is in a long format.
For square matrices (i.e., all variables correlated with all variables), something like this could be a first step:
model <- correlation::correlation(iris)
cells <- model$r
m <- matrix(cells, nrow = as.integer(sqrt(length(cells))), ncol=as.integer(sqrt(length(cells))), byrow = TRUE)
However, colnames and rownames still need to be named appropriately. Moreover, this wouldn't work in the case of uneven matrices, such as:
model <- correlation::correlation(
select(iris, Sepal.Length),
select(iris, starts_with("Petal"))
)
@strengejacke do you have by any chance any intuition?