I'm currently working on a correlation plot with gradient for a dataset involving social factors and outcomes such as grades.
The variable names are not that accessible, and I was wondering how to change, for example, "famrel" to "Family Relationship" on the axis.
I am using ggcorrplot() as well as ggplotly to add interactivity.
Any help would be much appreciated! I've been googling for two hours but cannot for the life of me find an applicable solution that doesn't involve altering the original dataframe.
df_corr <- select_if(df, is.numeric)
df_corr
corr <- round(cor(df_corr), 1)
p.mat <- cor_pmat(df_corr)
corr.plot <- ggcorrplot(corr,
hc.order = TRUE,
type = "lower",
)
ggplotly(corr.plot)
Above is my code; I have also attached a screenshot of the resulting chart.
I tried googling as well as searching stack overflow for the answer to my question, but was unsuccessful.
In addition to @Kat's option of directly editing the dataframe, you can also rename the column names and rownames directly in
corr
. Also be aware thatselect_if
has been superseded.If you only want to change a single value on the axes (e.g.,
famrel
), then you can edit a single rowname and a single column name like this: