Correspondence Analysis

対応分析の実行
library(dplyr)
library(stringr)
library(magrittr)
library(ggplot2)
library(rvest)
library(ggrepel)
library(ca)
# データの概要
label item1 item2 item3 item4 item5 item6 item 7
A     5     3     3     5     5     5     5
B     3     4     4     5     4     5     5
C     4     4     4     5     5     3     5
D     5     4     3     5     5     5     4
E     5     3     3     5     5     5     3
F     5     1     5     5     5     5     3
# labelの列をname属性に変換
rownames(dat) <- dat$label
# labelの列(1列目)を削除し対応分析
RE.ca <- ca(dat[, -1])
同時布置図(Symmetric Map)
label <- rownames(dat)
item <- c(rep("label", nrow(dat)), rep("item", ncol(dat[, -1]))    #labelとitemの数をそれぞれ指定
name <- c(label, colnames(dat[, -1]))
results <- data.frame(name, item, rbind(RE.ca$rowcoord[, 1 : 2], (RE.ca$colcoord[, 1 : 2])))
PointPlot <- 
  ggplot(results, aes(x = Dim1, y = Dim2, label = name, color = item, fill = item)) +
    geom_point(aes(colour = item, shape = item)) 
PointPlot+
  geom_label_repel(aes(Dim1, Dim2, fill = factor(item), label = name),
    fontface = 'bold', color = 'white',
    box.padding = unit(0.35, "lines"),
    point.padding = unit(0.5, "lines"),
    segment.color = 'grey70') +
  geom_hline(yintercept = 0, colour = "gray70") +
  geom_vline(xintercept = 0, colour = "gray70") +
  xlab("Dim 1") +
  ylab("Dim 2")