data <- read.csv("AJSI.csv") xtable <- matrix(0, nrow = 6, ncol = 6) n <- length(data$satisfy_1) for (i in 1:6) { for (j in 1:6) { for (k in 1:n) { if ( data$satisfy_1[k] == i & data$satisfy_2[k] == j ) xtable[i, j] <- xtable[i, j] + 1 } } } x <- c(rep(1, 6), rep(2, 6), rep(3,6), rep(4,6), rep(5, 6), rep(6,6) ) y <- c(rep(1:6, 6)) w <- c(xtable[1,], xtable[2,], xtable[3,], xtable[4,], xtable[5,], xtable[6,] ) df <- data.frame(x, y, w) df2 <- subset(df, w != 0) # バブルチャートを描く(方法1) plot(x, y, cex = sqrt(w), xlab = "満足度1", ylab = "満足度2") # バブルチャートを描く(方法2) library(ggplot2) ggplot(data = df2, aes(x = x, y = y, size = w)) + geom_point() + scale_size_area() + theme(legend.position = "none")