Asymmetric correlation coefficient matrix in R

Hi, community
Is it possible to output asymmetric correlation coefficient matrix and draw the plot(with significance mark)?
I just meet this question when practicing R, and now could do symmetric correlation analysis only now. Take the mtcars data in R as example data is ok.
Thanks for all the help.

Can you say more about what that is ?

@nirgrahamuk like this
Matrix of correlation coefficients with different horizontal and vertical coordinates. How could we output this type matrix and plot?


# seems there can be a lot of example making prep code ...
(vols_1 <- rbind(expand.grid(LETTERS[1],1:4),
      expand.grid(LETTERS[2],1:2)) |> mutate(vols=100,
  vname = paste0(Var1,Var2)) |> tibble())

(vs1 <- split(vols_1,~vname) |> 
    lapply(FUN=\(x){tibble(val = rnorm(n=x$vols,mean = x$mean,sd=x$sd))|>
        mutate(rn=row_number())}) )

(vs2 <- tibble(dplyr::bind_rows(vs1,.id = "vname")))

(example_inputs_1 <- pivot_wider(vs2,id_cols = "rn"
                                 ,names_from = "vname",
                                 values_from = val) |> select(-rn))
# end of example making prep

# a correlation result :
# are we just dropping columns and row ? 
cor(example_inputs_1) |> |> select(-B1,-B2) |> tibble::rownames_to_column() |>
1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.