0
으로 시각화합니다. 여러 항목 간의 상관 행렬을 생성하는 코드가 있습니다. 가장 좋은 방법으로 시각화하고 싶습니다. corrplot 함수를 사용하려고했지만 문제가 생겼습니다.복잡한 상관 행렬을 R
library(corrplot)
Orders<- structure(list(WHWorkOrderHeaderId = c(137413L, 137413L, 137413L,
137413L, 137413L, 137413L, 137413L, 137413L, 137413L, 137413L,
137413L, 137413L, 137429L, 137429L, 137429L, 137429L, 137429L,
137429L, 137429L, 137429L, 137429L, 137260L, 137260L, 137260L,
137260L, 137260L, 137260L, 137260L, 137260L, 137260L, 137260L,
136729L, 136729L, 136729L, 136729L, 136729L, 136729L, 136729L,
136729L, 136729L, 136729L, 136729L, 136729L, 136729L, 137902L,
137902L, 137902L, 137902L, 137902L, 137902L, 137902L, 137974L,
137974L, 138837L, 138837L, 138837L, 138837L, 138837L, 138837L,
139424L, 139424L, 139424L, 139424L, 139424L, 139424L, 139424L,
139424L, 139424L, 139642L, 139642L, 139642L, 139642L, 139642L,
139642L, 139642L, 140676L, 140676L, 140676L, 140676L, 140676L,
140676L, 140938L, 140938L, 140938L, 140938L, 140938L, 140938L,
140938L, 140938L, 140938L, 140938L, 141302L, 141302L, 141302L,
141302L, 141302L, 141302L, 138297L, 138297L, 138297L), OtherLangDescription = structure(c(17L,
16L, 34L, 19L, 25L, 32L, 18L, 35L, 15L, 27L, 13L, 22L, 16L, 26L,
5L, 20L, 19L, 14L, 29L, 35L, 27L, 17L, 16L, 30L, 26L, 5L, 19L,
14L, 31L, 29L, 27L, 23L, 24L, 16L, 30L, 8L, 19L, 14L, 32L, 9L,
31L, 35L, 27L, 21L, 24L, 30L, 26L, 5L, 14L, 32L, 31L, 26L, 5L,
11L, 24L, 31L, 15L, 27L, 13L, 11L, 17L, 24L, 10L, 19L, 32L, 6L,
31L, 33L, 23L, 11L, 17L, 4L, 10L, 19L, 31L, 23L, 11L, 4L, 10L,
19L, 31L, 11L, 17L, 16L, 14L, 25L, 12L, 31L, 7L, 1L, 2L, 23L,
3L, 35L, 15L, 27L, 28L, 17L, 24L, 16L), .Label = c(" Green Beans",
"Baladi Cabbage", "Baladi Garlic", "Banati Grape", "Barshomi Figs",
"Black Eggplant", "Cantaloupe", "Capsicum", "Carrot", "Chili Pepper",
"Classic Eggplant", "Cooking Potato", "Coriander", "Cucumber",
"Dill", "Flame Grape", "frying Potato", "Golden Onion", "Green pepper",
"Hot Pepper", "Local Celery ", "Local Eggplant", "Local Lemon",
"Local Pear", "Molokhia", "Momtaza Owais Mango", "Parsley", "Red Globe Grape",
"Red Onion", "Superior Grape", "Tomato", "White Eggplant ", "Zaghlol Dates",
"Zebdaya Mango", "Zucchini"), class = "factor")), .Names = c("WHWorkOrderHeaderId",
"OtherLangDescription"), row.names = c(NA, -100L), class = "data.frame")
Orders$OtherLangDescription <- as.factor(Orders$OtherLangDescription)
orderList <- unique(Orders$OtherLangDescription)
ListId <- lapply(orderList, function(x) subset(Orders, OtherLangDescription == x)$WHWorkOrderHeaderId)
Initial_Tab <- lapply(ListId, function(x) subset(Orders, WHWorkOrderHeaderId %in% x)$OtherLangDescription)
Correlation_Tab <- mapply(function(Product, ID) table(Product)/length(ID),
Initial_Tab, ListId)
colnames(Correlation_Tab) <- orderList
cor_per<- round(Correlation_Tab*100,2)
#View(cor_per)
#plot cor matrix
corrplot(Correlation_Tab, tl.pos="lt", type="upper",
tl.col="black", tl.cex=0.6, tl.srt=45, is.corr = FALSE,
addCoef.col="black", addCoefasPercent = TRUE,
sig.level=0.50, insig = "blank")
'corrplot' 패키지를로드 했습니까? 또는 당신의 문제는 정확히 무엇입니까? – Alex
@Alex 예 했어 – Believer
그런 다음 코드를 재현성있게 만들기 위해 질문에 추가하십시오. 그리고 당신의 문제가 무엇이고 당신이 원하는 것을 말하십시오. – Alex