-
Notifications
You must be signed in to change notification settings - Fork 0
/
GP_PCA.R
29 lines (23 loc) · 1.12 KB
/
GP_PCA.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
library("ggbiplot")
# Загружаем данные
data <- read.csv("/home/lizaku/PycharmProjects/verbal-aspect/GP_relative.csv", header = T, sep = ",")
an_data <- data[c("praes", "fut", "praet", "inf", "imper", "gerund", 'partcp.act.past', 'partcp.act.nonpast', 'partcp.pass.past', 'partcp.pass.nonpast')]
# Проводим анализ
GP.princomp <- princomp(an_data, scores=TRUE)
summary(GP.princomp)
# Доля дисперсии
props = round((GP.princomp$sdev^2/sum(GP.princomp$sdev^2)), 3)
# На графике
plot(GP.princomp)
# Для абсолютных частотностей
data <- read.csv("/home/lizaku/PycharmProjects/verbal-aspect/GP_relative.csv", header = T, sep = ",")
dataAdjusted <- data[, 3:11] - apply(data[, 3:11], 1, mean)
rownames(dataAdjusted) <- paste(data$lemma,data$aspect)
GP2.princomp <- princomp(dataAdjusted)
# simple plot
plot(GP2.princomp$scores)
text(GP2.princomp$scores, rownames(dataAdjusted))
# colored plot
g <- ggbiplot(GP2.princomp, obs.scale = 1, var.scale = 1, ellipse = TRUE, circe = FALSE, groups=data$aspect)
g <- g + theme(legend.direction='horizontal', legend.position="top")
print(g)