以下代码创建了一个不太可读的关联矩阵可视化:
1)文字太大,单元格内的数字不可读 2)x和y轴上的刻度不提供信息,因为它们太拥挤了
你能告诉我如何处理这些问题:
代码如下:
library(GGally)
library(ggplot2)
library(data.table)
library(ROSE)
library(dplyr)
#===================================================================================================================
# LOAD THE DATA
#===================================================================================================================
data(hacide)
train <- hacide.train
#=============================================================================================================
# FEATURE EXTRACTION
#=================================================================================================================
setDT(train)
train <- train %>% mutate(
x11 = ifelse(x1 < -1.4, 1, 0),
x12 = ifelse(((x1 >= -1.4) & (x1 < -0.74)), 1, 0),
x13 = ifelse(((x1 >= -0.74) & (x1 < 1)), 1, 0),
x14 = ifelse(x2 >= 1, 1, 0),
x21 = ifelse(x2 < -1.4, 1, 0),
x22 = ifelse(((x2 >= -1.4) & (x2 < -1)), 1, 0),
x23 = ifelse(((x2 >= -1) & (x2 < 0.5)), 1, 0),
x24 = ifelse(x2 >= 0.5, 1, 0),
x3 = x1 ^ 2 - x2
)
#=========================================================================================================
# EXAMINE CORRELATIONS
#=========================================================================================================
ggpairs(train ,
lower = list(continuous = wrap("points", color = "red", alpha = 0.5),
combo = wrap("box", color = "orange", alpha = 0.3),
discrete = wrap("facetbar", color = "yellow", alpha = 0.3) ),
diag = list(continuous = wrap("densityDiag", color = "blue", alpha = 0.5) ))
情节如下: