################################################################################### ### R code for "Liikumisverbid horisontaalsel ja vertikaalsel teljel" ### ### [Motion verbs along the horizontal and vertical axes: a sorting experiment] ### ### Piia Taremaa ### ### Keel ja Kirjandus 3/2021 ### ################################################################################### library(magrittr) library(dplyr) library(ggpubr) HV = read.delim("HV.txt", sep = "\t") str(HV) head(HV) nrow(HV) # MDS mds <- HV %>% dist() %>% cmdscale() %>% as_tibble() colnames(mds) <- c("Dim. 1", "Dim. 2") head(mds) # klasterdus / K-means clustering clust <- kmeans(mds, 4)$cluster %>% as.factor() mds <- mds %>% mutate(groups = clust) # joonis/plot p = ggscatter(mds, x = "Dim. 1", y = "Dim. 2", label = rownames(HV), color = "groups", palette = c("black","black","black","black"), size = 2, ellipse = TRUE, ellipse.type = "convex", repel = TRUE, shape = "groups", show.legend.text = F) ggpar(p, legend.title = "Verbirühm") # verbirühm / verb group