强制 corrplot 在相关矩阵图中显示尾随零

问题描述 投票:0回答:1

我正在 R 中使用 mtcars 数据集,使用

corrplot
包绘制相关矩阵。我的问题是我希望
wt
disp
之间的 0.9 值显示为 0.90。我注意到当我将
method
参数更改为“number”而不是“shade”时这是可能的,但我希望我的绘图使用“shade”参数。

有没有办法可以转换我的数据,以便 corrplot 显示尾随零?

我的代码如下:

library(tidyverse)
library(corrplot)

data("mtcars")

corr_df = mtcars %>%
  select(mpg, disp, hp, drat, wt, qsec)

mat = cor(corr_df, method = "spearman")

corrplot(mat, method = "shade",  tl.col = "black", 
                         addCoef.col = "black", type = "lower",  
                         order = "original" , diag = F,
                         addgrid.col = "black", tl.srt = 45, number.digits = 2)

here

我尝试使用

number.digits
参数,但当它设置为 2 位数字时,输出仍然是 0.9,当它设置为 3 位数字时,输出变为 0.899。

r r-corrplot
1个回答
0
投票

目前该软件包尚未实现此功能,并且该软件包已经有一段时间没有收到任何更新了。

已提出问题,并且有解决该问题的拉取请求

在拉取请求被接受之前,您能做的最好的事情就是安装修补版本:

devtools::install_github("the-mad-statter/corrplot@add_format")
© www.soinside.com 2019 - 2024. All rights reserved.