Skip to content

Correlation "long" data to matrix #12

Closed
@DominiqueMakowski

Description

@DominiqueMakowski

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement 💥Implemented features can be improved or revised

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions