I have a table with three columns containing my first variable, my second variable, and their estimated correlation (estimates coming from a brmsfit model).
As an example, let's consider the following table:
tibble::tribble(
~a, ~b, ~est,
"fro", "fcr", "0.061 [-0.276, 0.38]",
"fro", "nek", "0.115 [-0.218, 0.421]",
"nek", "fcr", "0.154 [-0.169, 0.476]",
"ooi", "fcr", "-0.022 [-0.352, 0.305]",
"ooi", "fro", "0.006 [-0.326, 0.323]",
"ooi", "nek", "0.173 [-0.151, 0.486]",
"ooi", "zyg", "0.039 [-0.29, 0.362]",
"zyg", "fcr", "-0.02 [-0.347, 0.317]",
"zyg", "fro", "0.092 [-0.245, 0.406]",
"zyg", "nek", "0.315 [0.011, 0.613]"
)
I would like to reshape it in the form of a correlation matrix. I know some packages permits to do the exact inverse operation (e.g., the corrr::stretch() function), but I am not aware of an easy solution for reshaping a wide dataframe into a correlation matrix.
Any idea ?