r-corrplot

length of 'dimnames' [2] not equal to array extent when using corrplot function from a matrix read from a csv file

我的未来我决定 提交于 2019-12-07 01:46:47
问题 I wanna read the data from a csv file, save it as a matrix and use it for visualization. data<-read.table("Desktop/Decision_Tree/cor_test_.csv",header = F,sep = ",") data V1 V2 V3 V4 V5 V6 1 1.00 0.00 0.00 0.00 0.00 0 2 0.11 1.00 0.00 0.00 0.00 0 3 0.12 0.03 1.00 0.00 0.00 0 4 -0.04 0.54 0.32 1.00 0.00 0 5 -0.12 0.57 -0.09 0.26 1.00 0 6 0.21 -0.04 0.24 0.18 -0.21 1 It goes well. But then: corrplot(data, method = 'color', addCoef.col="grey") It is said that: Error in matrix(unlist(value,

how to place colorlegend (corrplot) in graphic

依然范特西╮ 提交于 2019-12-06 03:49:20
I am using corrplot to create a correlation heatmap, but I don't like the default legend - it is too big. So I was trying to use the colorlegend() to add the legend after I create the plot (and disable the default legend with cl.pos="n" ). Only problem is that I can't figure out how to change the position of the legend - it ends up on the lower left. Ideally, I could place it on the top right, but I looked through the options for colorlegend and plot and can't figure this out. For example: # load libraries and create color scale library(corrplot) library(RColorBrewer) scalebluered <-

length of 'dimnames' [2] not equal to array extent when using corrplot function from a matrix read from a csv file

妖精的绣舞 提交于 2019-12-05 04:51:14
I wanna read the data from a csv file, save it as a matrix and use it for visualization. data<-read.table("Desktop/Decision_Tree/cor_test_.csv",header = F,sep = ",") data V1 V2 V3 V4 V5 V6 1 1.00 0.00 0.00 0.00 0.00 0 2 0.11 1.00 0.00 0.00 0.00 0 3 0.12 0.03 1.00 0.00 0.00 0 4 -0.04 0.54 0.32 1.00 0.00 0 5 -0.12 0.57 -0.09 0.26 1.00 0 6 0.21 -0.04 0.24 0.18 -0.21 1 It goes well. But then: corrplot(data, method = 'color', addCoef.col="grey") It is said that: Error in matrix(unlist(value, recursive = FALSE, use.names = FALSE), nrow = nr, : length of 'dimnames' [2] not equal to array extent I don

How can I highlight significant correlation in corrplot in R?

落花浮王杯 提交于 2019-12-04 06:44:20
问题 In corrplot in R, we can highlight insignificant correlation (<0.05) by supplying p-value matrix and using function "insig" and "pch". But I want highlight only Significant correlation having p-value less than 0.05. Is there any way to do the opposite? Best regards Shriram 回答1: I looked into the source code of corrplot . As far as I understand the code, it is not possible to do the exact opposite to the significant values. The only option that comes really close to what you want is defining

Manipulating axis titles in ggpairs (GGally)

情到浓时终转凉″ 提交于 2019-12-03 04:22:19
问题 I'm using the code below to generate the following chart. # Setup data(airquality) # Device start png(filename = "example.png", units = "cm", width = 20, height = 14, res = 300) # Define chart pairs.chrt <- ggpairs(airquality, lower = list(continuous = "smooth"), diag = list(continuous = "blank"), upper = list(continuous = "blank")) + theme(legend.position = "none", panel.grid.major = element_blank(), axis.ticks = element_blank(), axis.title.x = element_text(angle = 180, vjust = 1, color =

Manipulating axis titles in ggpairs (GGally)

折月煮酒 提交于 2019-12-02 17:46:50
I'm using the code below to generate the following chart. # Setup data(airquality) # Device start png(filename = "example.png", units = "cm", width = 20, height = 14, res = 300) # Define chart pairs.chrt <- ggpairs(airquality, lower = list(continuous = "smooth"), diag = list(continuous = "blank"), upper = list(continuous = "blank")) + theme(legend.position = "none", panel.grid.major = element_blank(), axis.ticks = element_blank(), axis.title.x = element_text(angle = 180, vjust = 1, color = "black"), panel.border = element_rect(fill = NA)) # Device off and print print(pairs.chrt) dev.off() I'm

How to colourise some cell borders in R corrplot?

给你一囗甜甜゛ 提交于 2019-12-02 11:58:21
问题 I would like to keep some cells in attention by making their borders clearly distinct from anything else. The parameter rect.col is used to colorise all borders but I want to colorise only borders of the cells (3,3) and (7,7), for instance, by any halo color etc heat.colors(100) or rainbow(12) . Code: library("corrplot") library("psych") ids <- seq(1,11) M.cor <- cor(mtcars) colnames(M.cor) <- ids rownames(M.cor) <- ids p.mat <- psych::corr.test(M.cor, adjust = "none", ci = F) p.mat <- p.mat[

How to colourise some cell borders in R corrplot?

廉价感情. 提交于 2019-12-02 04:10:38
I would like to keep some cells in attention by making their borders clearly distinct from anything else. The parameter rect.col is used to colorise all borders but I want to colorise only borders of the cells (3,3) and (7,7), for instance, by any halo color etc heat.colors(100) or rainbow(12) . Code: library("corrplot") library("psych") ids <- seq(1,11) M.cor <- cor(mtcars) colnames(M.cor) <- ids rownames(M.cor) <- ids p.mat <- psych::corr.test(M.cor, adjust = "none", ci = F) p.mat <- p.mat[["r"]] corrplot(M.cor, method = "color", type = "upper", tl.col = 'black', diag = TRUE, p.mat = p.mat,

R: Titles cut in half with par()

ぃ、小莉子 提交于 2019-12-01 19:20:02
I have this figure: require(corrplot) par(oma=c(0,0,2,0), mfrow = c(1, 3)) for (country in c("Italy","Germany","Afghanistan")) { corrplot.mixed(cor(data.frame(v1=rnorm(40), v2=rnorm(40), v3=rnorm(40), v4=rnorm(40), v5=rnorm(40), v6=rnorm(40), v7=rnorm(40), v8=rnorm(40)), use="pairwise.complete.obs"), main=country) } par(mfrow = c(1, 1)) which produces titles cut in half: Following this answer I set oma=c(0,0,2,0) but it does't affect the results. I am not sure which margin I should modify. I looked at ?par and modified "oma", "omd", "omi", "mai", "mar" with no result. I found that passing mar

Change text color in corrplot.mixed

戏子无情 提交于 2019-12-01 09:17:35
In the r package corrplot , you can mix the type of figure on the lower and upper half of a correlation matrix to make a nice visual. I would like to have numbers on the lower half of my matrix, and ellipses on the top half of the matrix - that is all fine. But, with my data I cannot see some of the correlation numbers since they are near 0. Below is the code I am using and current output. Is there a way to change the text color for the lower half of the matrix? I'd like to change the colors of the correlation coefficients to not be white (they don't need to be red to blue, black would be ok).