--- title: "faktorid2" output: html_document --- ```{r} library(languageR) head(dutchSpeakersDist) head(dutchSpeakersDistMeta) dutchSpeakersDist.d=dist(dutchSpeakersDist) dutchSpeakersDist.mds=cmdscale(dutchSpeakersDist.d, k=3) #ruumiline head(dutchSpeakersDist.mds) p=dutchSpeakersDist.mds #install.packages("plot3D") library(plot3D) points3D(p[,1], p[,2], p[,3]) asukohad=cmdscale(dutchSpeakersDist.d, k=2) #tasand head(asukohad) plot(asukohad) asukohad=cmdscale(dutchSpeakersDist.d, k=1) # joon head(asukohad) plot(asukohad, sample(0, nrow(asukohad), replace = TRUE), col=rgb(0, 0, 0, 0.3)) #Paigutage multidimensionaalse skaleerimise abil kahemõõtmelisele joonisele #ühe päeva tunnid, nii et sarnasema ilmaga tunnid oleksid lähestikku ilm=read.table("http://www.tlu.ee/~jaagup/andmed/ilm/harkutund.txt", header=TRUE, sep=",") ilmtervik=ilm[complete.cases(ilm), ] ilmskaleeritud=scale(ilmtervik[1:24, 5:11]) ilmskaleeritud head(ilm, 24) asukohad=cmdscale(dist(ilmskaleeritud), 2) asukohad plot(asukohad, type="n") text(asukohad, cex=0.5) plot(cmdscale(dist(scale(ilmtervik[1:2000, 4:11])), 2)) asukohad=cmdscale(dist(scale(ilmtervik[1:2000, 4:11])), 2) plot(asukohad, type="n") text(x=asukohad[, 1], y=asukohad[, 2], labels=ilmtervik[1:2000, "Kuu"]) ryhmad=kmeans(asukohad, centers=3) plot(asukohad, type="n") text(x=asukohad[, 1], y=asukohad[, 2], labels=ryhmad$cluster) plot(asukohad, col=ryhmad$cluster) head(lexicalMeasures) plot(hclust(dist(cor(lexicalMeasures[, -1])))) ilm=read.table("http://www.tlu.ee/~jaagup/andmed/ilm/harkutund.txt", header=TRUE, sep=",") ilmtervik=ilm[complete.cases(ilm), ] ilmskaleeritud=scale(ilmtervik[2000:5000, 4:11]) plot(hclust(dist(cor(ilmskaleeritud)))) jaanuar1=ilmtervik[1:24, 5:11] plot(hclust(dist(cor(scale(jaanuar1))))) plot(hclust(dist(cor(scale(t(jaanuar1)))))) jaanuar1 t(jaanuar1) ilmskaleeritud=scale(ilmtervik[ilmtervik$Kuu==1 & ilmtervik$Kell=="10:00", 4:11]) plot(hclust(dist(cor(ilmskaleeritud)))) row.names(ilmskaleeritud)=1:31 plot(hclust(dist(cor(t(ilmskaleeritud))))) ryhmad=cutree(hclust(dist(cor(t(ilmskaleeritud)))), k=3) #joon kolme haru kohalt plot(ilmskaleeritud[, c("TA1H", "WS1H")], type="n") #teljed text(ilmskaleeritud[, c("TA1H", "WS1H")], labels = row.names(ilmskaleeritud), col=ryhmad) ```