Attaching package: 'dplyr'
The following object is masked from 'package:sjlabelled':
as_label
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
tscs231forMCA <- select(tscs231,
c(Tai,imza,imec,imwo,imcu,lobe,imsu,
jpjf,jptz,jpss,
hkjf,hktz,hkss,
chjf,chtz,chss,
dnjf,dntz,dnss
))
tscs231forMCA.nona <- na.omit(tscs231forMCA)
par(mfrow=c(2,3))
for (i in 1:ncol(tscs231forMCA.nona)) {
plot(tscs231forMCA.nona[,i], main=colnames(tscs231forMCA.nona)[i],
ylab = "Count", col="steelblue", las = 2, ylim=c(0,1500))
}
library(FactoMineR)
library(factoextra)
Warning: package 'factoextra' was built under R version 4.5.2
Loading required package: ggplot2
Attaching package: 'ggplot2'
The following object is masked from 'package:sjPlot':
set_theme
The following object is masked from 'package:sjlabelled':
as_label
Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
names(tscs231forMCA.nona)
[1] "Tai" "imza" "imec" "imwo" "imcu" "lobe" "imsu" "jpjf" "jptz" "jpss"
[11] "hkjf" "hktz" "hkss" "chjf" "chtz" "chss" "dnjf" "dntz" "dnss"
res<-MCA(tscs231forMCA.nona, ncp=10, graph= F)
summary(res, nb.dec = 3, nbelements=10, nbind = 10,
ncp = 2, file="result2dim.txt")
res$dimdesc <- dimdesc(res, axes = 1:10)
write.infile(res$dimdesc, file ="MCAresults",append=F)
write.infile(res$eig, file ="MCAresults",append=T)
write.infile(res$var, file ="MCAresults",append=T)
fviz_screeplot(res, ncp=10)
Warning in geom_bar(stat = "identity", fill = barfill, color = barcolor, :
Ignoring empty aesthetic: `width`.
corrplot(res$var$cos2, is.corr=FALSE, tl.cex=.6)
plot(res, axes=c(1, 2), new.plot=TRUE, choix="var",
col.var="red", col.quali.sup="darkgreen",
label=c("quali.sup", "quanti.sup", "var"),
invisible=c("ind"),
autoLab = "yes",
# title="The Distribution of Variables on the MCA Factor Map",
title="", cex=0.8,
xlim=c(0,0.4), ylim=c(0, 0.6))
Warning: Removed 12 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 12 rows containing missing values or values outside the scale range
(`geom_text_repel()`).
plot(res, axes=c(1, 2), new.plot=TRUE,
col.var="red", col.ind="black", col.ind.sup="black",
col.quali.sup="darkgreen", col.quanti.sup="blue",
label=c("var"), cex=0.8,
selectMod = "cos2 70",
invisible=c("ind", "quali.sup"),
autoLab = "yes",
title="")
Warning: ggrepel: 42 unlabeled data points (too many overlaps). Consider
increasing max.overlaps
plot(res, axes=c(1, 2), new.plot=TRUE,
col.var="red", col.ind="black", col.ind.sup="black",
col.quali.sup="darkgreen", col.quanti.sup="blue",
label=c("var"), cex=0.8,
selectMod = "cos2 30", #共52個變數
invisible=c("ind", "quali.sup"),
xlim=c(-1.2,1.2), ylim=c(-0.6,2),
autoLab = "yes",
title="")
Warning: Removed 29 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 29 rows containing missing values or values outside the scale range
(`geom_text_repel()`).
Warning: ggrepel: 4 unlabeled data points (too many overlaps). Consider
increasing max.overlaps