Dear friends, it is a pleasure to join me in this group. I'm using a Multiple Correspondence Analysis example (MCA). Question:
How do I change the font size in the chart (not the font size of the titles axes), but to the variables labels size.
Below the script:
#Usando MCA
# load packages
require(FactoMineR)
require(ggplot2)
# load data tea
data(tea)
tea
names(tea)
# select these columns
newtea = tea[, c("Tea", "How", "how", "sugar", "where", "always")]
newtea
# take a peek
head(newtea)
names(newtea)
str(newtea)
cats = apply(newtea, 2, function(x) nlevels(as.factor(x)))
cats
# apply MCA
mca1 = MCA(newtea, graph = FALSE)
# list of results
mca1
# table of eigenvalues
mca1$eig
#We can use the package "ggplot2()" to get a nice plot:
# data frame with variable coordinates
mca1_vars_df = data.frame(mca1$var$coord, Variable = rep(names(cats), cats))
# data frame with observation coordinates
mca1_obs_df = data.frame(mca1$ind$coord)
# plot of variable categories
g1<-ggplot(data=mca1_vars_df,
aes(x = Dim.1, y = Dim.2, label = rownames(mca1_vars_df))) +
geom_hline(yintercept = 0, colour = "gray70") +
geom_vline(xintercept = 0, colour = "gray70") +
geom_text(aes(colour=Variable)) +
ggtitle("MCA plot of variables using R package FactoMineR")
g1 + theme(axis.title.x = element_text(face="bold", colour="#990000", size=30),
axis.text.x = element_text(angle=90, vjust=0.5, size=10))
# MCA plot of observations and categories
ggplot(data = mca1_obs_df, aes(x = Dim.1, y = Dim.2)) +
geom_hline(yintercept = 0, colour = "gray70") +
geom_vline(xintercept = 0, colour = "gray70") +
geom_point(colour = "gray50", alpha = 0.7) +
geom_density2d(colour = "gray80") +
geom_text(data = mca1_vars_df,
aes(x = Dim.1, y = Dim.2,
label = rownames(mca1_vars_df), colour = Variable)) +
ggtitle("MCA plot of variables using R package FactoMineR") +
scale_colour_discrete(name = "Variable")
I live in Amazonas-Brasil.
Thanks.
Edson Lira
Statistical