errorProb <- function(targetRate,difference,size) {
pbinom(ceiling((targetRate-difference)*size),
size=size,prob=targetRate)
}
size <- actualSize(0.045,0.004,0.05)
size
print(errorProb(0.045,0.004,size))
print(errorProb(0.045,0.004,7622))
set.seed(235236)
d <- data.frame(EarnedIncome=100000*rlnorm(100),  CapitalGains=100000*rlnorm(100))
print(with(d,cor(EarnedIncome,CapitalGains)))
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
with(d,cor.test(EarnedIncome,CapitalGains,method='spearman'))
ctest <-with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’)
sigr::wrapCorTest(ctest)
;
)
ctest <-with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’)
sigr::wrapCorTest(ctest()
ctest <-with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’)
sigr::wrapCorTest(ctest)
install.packages("sigr")
library("sigr")
sigr::wrapCorTest(ctest)
ctest <-with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’)
)
)
ctest <- with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’))
ctest <- with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’))
ctest <- with(d,cor.test(EarnedIncome,CapitalGains,method='spearman’))
ctest <- with(d,cor.test(EarnedIncome,CapitalGains,method='spearman'))
sigr::wrapCorTest(ctest)
library('rpart')
d <- read.csv("~/Downloads/Archaeal_tfpssm.csv",header = F)
levels(d[,2])
head(d[,5600:5603])
# select subset of the data
tmp <- d[c(seq(1,700,25), seq(700,800,5)),]
# model using decision tree
model <- rpart(V2 ~ V3 + V4 + V5600 + V5601 + V5602,
data=tmp, control=rpart.control(maxdepth=4),
method="class")
# make confusion matrix tabel
resultframe <- data.frame(truth=tmp$V2,
pred=predict(model, type="class"))
(rtab <- table(resultframe))
dim(tmp)
dim(d)
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
set.seed(235236)
d <- data.frame(EarnedIncome=100000*rlnorm(100),  CapitalGains=100000*rlnorm(100))
print(with(d,cor(EarnedIncome,CapitalGains)))
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
with(d,cor.test(EarnedIncome,CapitalGains,method='spearman'))
sigr::wrapCorTest(ctest)
set.seed(235236)
d <- data.frame(EarnedIncome=100000*rlnorm(100),  CapitalGains=100000*rlnorm(100))
print(with(d,cor(c(0.1,0.2),c(0.2,0.4))))
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
with(d,cor.test((c(0.1,0.2),c(0.2,0.4)),method='spearman'))
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
with(d,cor.test(c(0.1,0.2),c(0.2,0.4)),method='spearman'))
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
with(d,cor.test(c(0.1,0.2),c(0.2,0.4)),method='spearman')
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
cor.test(c(0.1,0.2),c(0.2,0.4)),method='spearman')
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
cor.test((c(0.1,0.2),c(0.2,0.4)),method='spearman')
?cor.test
with(d,cor(EarnedIncome,CapitalGains,method='spearman'))
cor.test(c(0.1,0.2),c(0.2,0.4),method='spearman')
a <- c(0.1,0.2)
b <- c(0.3,0.4)
cor(a,a)
cor(a,b)
c <- c(0.2, 0.4)
d <- c(0.4,0.8)
cor(a,c)
cor(a,d)
data(iris)
head(iris, 3)
log.ir <- log(iris[, 1:4])
summary(iris)
ir.species <- iris[, 5]
ir.pca <- prcomp(log.ir,center = TRUE, scale. = TRUE)
?prcomp
print(ir.pca)
summary(ir.pca)
plot(ir.pca, type = "l")
library(ggbiplot)
g <- ggbiplot(ir.pca, obs.scale = 1, var.scale = 1, groups = ir.species)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', legend.position = 'top')
print(g)
install.packages("ggbiplot")
sample(1..13)
sample(seq(1,13)
)
sample(seq(1,13))
sample(seq(1,13))
sample(seq(1,13))
sample(seq(1,13))
sample(seq(1,14))
?ls
.Ob <- 1
ls(pattern = "O")
ls(pattern= "O", all.names = TRUE)
scatter.ggplot <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
scatter.ggplot
scatter.ggplot <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
library("gglot2")
library("gglot")
library("ggplot2")
library("ggvis")
scatter.ggplot <- ggplot(mtcars, aes(x=wt, y=mpg)) + geom_point()
scatter.ggplot
scatter.ggvis <- mtcars %>% ggvis(x = ~wt, y = ~mpg) %>% layer_points() %>% set_options(width = img.width, height = img.height)
scatter.ggvis
mtcars %>% ggvis(~wt, ~mpg) %>% layer_points() %>% layer_model_predictions(model = "lm", se = TRUE)
mtcars %>% ggvis(x = ~wt, y = ~mpg) %>% layer_points()
mtcars %>%
ggvis(~wt, ~mpg, fill = ~factor(cyl)) %>%
layer_points() %>%
group_by(cyl) %>%
layer_model_predictions(model = "lm", se = TRUE)
line.ggvis <- mtcars.mean %>% ggvis(x = ~cyl, y = ~mpg_mean, stroke = ~am) %>% layer_lines() %>% set_options(width = img.width, height = img.height)
line.ggvis
plot(density(mtcars$wt))
?density
plot(density(mtcars$wt, kernel = "cosine"))
plot(density(mtcars$wt, kernel = "cosine"))
plot(density(mtcars$wt, kernel = "triangular"))
mtcars %>% ggvis(x = ~wt) %>%
layer_densities( adjust = input_slider(.1, 2, value = 1, step = .1, label = "Bandwidth adjustment"),
kernel = input_select( c("Gaussian" = "gaussian", "Epanechnikov" = "epanechnikov", "Rectangular" = "rectangular", "Triangular" = "triangular", "Biweight" = "biweight", "Cosine" = "cosine", "Optcosine" = "optcosine"), label = "Kernel") )
mtcars %>% ggvis(~mpg, ~disp, size = ~vs) %>% layer_points()
mtcars %>% ggvis(~wt, ~mpg, size := 300, opacity := 0.4) %>% layer_points()
mtcars %>% ggvis(~wt, ~mpg, size := input_slider(10, 100), opacity := input_slider(0, 1) ) %>% layer_points()
library(shiny)
runExample("01_hello")
library(shiny)
ui <- fluidPage(
# App title ----
titlePanel("Hello Shiny!"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel(
# Input: Slider for the number of bins ----
sliderInput(inputId = "bins",
label = "Number of bins:",
min = 1,
max = 50,
value = 30)
),
# Main panel for displaying outputs ----
mainPanel(
# Output: Histogram ----
plotOutput(outputId = "distPlot")
)
)
)
server <- function(input, output) {
# Histogram of the Old Faithful Geyser Data ----
# with requested number of bins
# This expression that generates a histogram is wrapped in a call
# to renderPlot to indicate that:
#
# 1. It is "reactive" and therefore should be automatically
#    re-executed when inputs (input$bins) change
# 2. Its output type is a plot
output$distPlot <- renderPlot({
x    <- faithful$waiting
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = "#75AADB", border = "white",
xlab = "Waiting time to next eruption (in mins)",
main = "Histogram of waiting times")
})
}
shinyApp(ui = ui, server = server)
runApp('Downloads/web1.R')
library(shiny)
runExample("01_hello")
runApp('Downloads/web1.R')
?aes
head(iris, 3)
summary(iris)
log.ir <- log(iris[, 1:4])
summary(log.ir)
prcomp(iris[,1:4],center = TRUE, scale. = TRUE)
prcomp(log.ir,center = TRUE, scale. = TRUE)
print_clusters <- function(labels, k) {
for(i in 1:k) {
print(paste("cluster", i))
print(protein[labels==i,c("Country","RedMeat","Fish","Fr.Veg")])
}
}
setwd("~/Dropbox/13_NCCU/courses/DataScience_資料科學實務/codes/code08.unsup/protein")
protein <- read.table("protein.txt", sep="\t", header=TRUE)
vars.to.use <- colnames(protein)[-1]
pmatrix <- scale(protein[,vars.to.use])
pcenter <- attr(pmatrix, "scaled:center")
pscale <- attr(pmatrix, "scaled:scale")
d <- dist(pmatrix, method="euclidean")
pfit <- hclust(d, method="ward")
plot(pfit, labels=protein$Country)
plot(pfit, labels=protein$Country)
rect.hclust(pfit, k=5)
groups <- cutree(pfit, k=5)
print_clusters(groups, 5)
library(ggplot2)
princ <- prcomp(pmatrix)
nComp <- 4
project <- predict(princ, newdata=pmatrix)[,1:nComp]
project.plus <- cbind(as.data.frame(project),
cluster=as.factor(groups),
country=protein$Country)
ggplot(project.plus, aes(x=PC1, y=PC2)) +
geom_point(aes(shape=cluster)) +
geom_text(aes(label=country),
hjust=0, vjust=1)
ggplot(project.plus, aes(x=PC3, y=PC4)) +
geom_point(aes(shape=cluster)) +
geom_text(aes(label=country),
hjust=0, vjust=1)
x=matrix (rnorm (30*3) , ncol =3)
dd=as.dist(1- cor(t(x)))
plot(hclust (dd, method ="complete"), xlab="", sub ="")
library(fpc)
kbest.p<-5
pclusters <- kmeans(pmatrix, kbest.p, nstart=100, iter.max=100)
pclusters
pclusters$centers
pclusters$size
groups <- pclusters$cluster
print_clusters(groups, kbest.p)
pclusters <- kmeans(pmatrix, kbest.p, nstart=100, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=100, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
> pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
> pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=1, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=10, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
set.seed(3)
pclusters <- kmeans(pmatrix, kbest.p, nstart=5, iter.max=100)
pclusters$tot.withinss
library(reshape2)
source("../CH.R")
source("../WSS.R")
clustcrit <- ch_criterion(pmatrix, 10, method="hclust")
critframe <- data.frame(k=1:10, ch=scale(clustcrit$crit), wss=scale(clustcrit$wss))
critframe
?melt
ggplot(critframe, aes(x=k, y=score, color=measure)) +
geom_point(aes(shape=measure)) + geom_line(aes(linetype=measure)) +
scale_x_continuous(breaks=1:10, labels=1:10)
critframe <- melt(critframe, id.vars=c("k"), variable.name="measure", value.name="score")
critframe
ggplot(critframe, aes(x=k, y=score, color=measure)) +
geom_point(aes(shape=measure)) + geom_line(aes(linetype=measure)) +
scale_x_continuous(breaks=1:10, labels=1:10)
clustering.ch <- kmeansruns(pmatrix, krange=1:10, criterion="ch")
clustering.ch$bestk
clustering.ch$crit
clustering.asw <- kmeansruns(pmatrix, krange=1:10, criterion="asw")
clustering.asw$bestk
critframe <- data.frame(k=1:10, ch=scale(clustering.ch$crit),
asw=scale(clustering.asw$crit))
critframe <- melt(critframe, id.vars=c("k"), variable.name="measure", value.name="score")
ggplot(critframe, aes(x=k, y=score, color=measure)) +geom_point(aes(shape=measure)) + geom_line(aes(linetype=measure)) + scale_x_continuous(breaks=1:10, labels=1:10)
ggplot(critframe, aes(x=k, y=score, color=measure)) +geom_point(aes(shape=measure)) + geom_line(aes(linetype=measure)) + scale_x_continuous(breaks=1:10, labels=1:10)
