0

Is there anyway I can edit my cor_df table (image below) to rename the labels, remove "rowname," and generally make it look prettier for publication? And, is there a command I can use to generate latex output?

This is how I generated my correlation table:

library(corrr)
library(dplyr)
Corrbata <- murder.data %>%
  dplyr::select(c(murderrate, prexconv, exec)) %%
  corrr::correlate(x = .) %>% 
  shave() %>%
  fashion(, decimals = 2) %>%
  fashion(na_print = "")

CorrData

This is what my cor_df looks like, which looks ugly :) This is what my cor_df looks like, which looks ugly :)

Ian Campbell
  • 23,484
  • 14
  • 36
  • 57
  • 2
    Hi dizerascal, welcome to Stack Overflow. In the future, please provide your code as text rather than an image. It will be much easier to help if you provide at least a sample of your data with `dput(murder.data)` or if your data is very large `dput(murder.data[1:20,])`. You can [edit] your question and paste the output. Please surround the output with three backticks (```) for better formatting. See [How to make a reproducible example](https://stackoverflow.com/questions/5963269/) for more info. – Ian Campbell Jun 18 '20 at 20:28

1 Answers1

0

Been a long time since I use latex, and not so familiar with how you render latex with RMarkdown. Here's a shot:

library(kableExtra)
cormat = round(cor(mtcars[,c("mpg","cyl","hp")]),digits=2)
cormat[!lower.tri(cormat)]=""
kable(cormat,"latex")

\begin{tabular}{l|l|l|l}
\hline
  & mpg & cyl & hp\\
\hline
mpg &  &  & \\
\hline
cyl & -0.85 &  & \\
\hline
hp & -0.78 & 0.83 & \\
\hline
\end{tabular}

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72