source("getFreqDir.R")
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
univTable <- getFreqDir("univ")
hc <- hclust(dist(t(univTable)))
plot(hc)
rect.hclust(hc, k=3, border="red")
hc <- hclust(dist(t(univTable), method = "canberra"), method = "ward.D2")
plot(hc)
rect.hclust(hc, k=3, border="red")
hc <- hclust(dist(t(univTable), method = "cosine"), method = "ward.D2")
plot(hc)
rect.hclust(hc, k=3, border="red")
top15<-sort(rowSums(univTable),decreasing=TRUE)[1:15]
names(top15)
## [1] "the" "and" "of" "to" "university"
## [6] "in" "a" "as" "is" "that"
## [11] "with" "for" "osaka" "research" "society"
TFtop15<-univTable[rownames(univTable) %in% names(top15),]
hc <- hclust(dist(t(TFtop15), method = "canberra"), method = "ward.D2")
plot(hc)
rect.hclust(hc, k=2, border="red")
TFtop15<-univTable[rownames(univTable) %in% names(top15),]
hc <- hclust(dist(TFtop15, method = "canberra"), method = "ward.D2")
plot(hc)
library(wordcloud)
## Loading required package: RColorBrewer
colnames(univTable)
## [1] "kyoto1" "kyoto2" "osaka1" "osaka2" "osaka3" "osaka4" "tokyo1"
## [8] "tokyo2" "waseda1" "waseda2"
ncol(univTable)
## [1] 10
comparison.cloud(univTable[,c(3,6)],max.words=20)
comparison.cloud(univTable[,c(F,T,F,F,F,T,F,F,F,T)],max.words=20)
head(brewer.pal.info[])
rownames(brewer.pal.info[])
## [1] "BrBG" "PiYG" "PRGn" "PuOr" "RdBu" "RdGy"
## [7] "RdYlBu" "RdYlGn" "Spectral" "Accent" "Dark2" "Paired"
## [13] "Pastel1" "Pastel2" "Set1" "Set2" "Set3" "Blues"
## [19] "BuGn" "BuPu" "GnBu" "Greens" "Greys" "Oranges"
## [25] "OrRd" "PuBu" "PuBuGn" "PuRd" "Purples" "RdPu"
## [31] "Reds" "YlGn" "YlGnBu" "YlOrBr" "YlOrRd"
binfo<-brewer.pal.info[]
palets <-rownames(binfo[binfo$maxcolors>10,])
tmpPalet = palets[1]
binfo[rownames(binfo)==tmpPalet,]
(maxNum=binfo[rownames(binfo)==tmpPalet,][1])
wordcloud(rownames(univTable),univTable$osaka4,
colors=brewer.pal(as.integer(maxNum),tmpPalet))
### パレットの変更
tmpPalet = palets[3]
(maxNum=binfo[rownames(binfo)==tmpPalet,][1])
wordcloud(rownames(univTable),univTable$osaka4,
colors=brewer.pal(as.integer(maxNum),tmpPalet),min.freq=4)