This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the plot.
#For example, in the first row: #Area: 15.26 #Perimeter: 14.84
#Compactness: 0.871 #Length of Kernel: 5.763 #Width of Kernel: 3.312
#Asymmetry Coefficient: 2.221 #Length of Kernel Groove: 5.22 #Type of
Wheat i.e. kama, rosa, canadian
View(seeds_dataset) seeds_dataset <- read.delim(“~/seeds_dataset.txt”, header=FALSE) View(seeds_dataset)
scaled_data <- scale(seeds_dataset)
seeds_dataset <- na.omit(seeds_dataset)
View(seeds_dataset)
summary(seeds_dataset)
scaled_data <- scale(seeds_dataset)
de <- dist(scale(seeds_dataset)) # Standardizing
he <- hclust(de)
plot(he) plot(he, hang=-0.1, labels=seeds_dataset[[‘V8’]], cex=0.5) # cex to decrease the font size
clus3e <- cutree(he, 3)
cm <- table(clus3e, seeds_dataset$V8) cm
Error<-100*(1- sum(diag(cm))/sum(cm)) Error
library(cluster) sil<-silhouette(clus3e,de) plot(sil) # Plot the Silhouettes, cluster co-efficient having close to 1 is better then others
set.seed(1234) d<- dist(scale(seeds_dataset[-5])) methds<- c(‘complete’,‘single’,‘average’) avgS<-matrix(NA, ncol=3, nrow=5,dimnames=list(2:6, methds))
for(k in 2:6) { for(m in seq_along(methds)) {h<- hclust(d, meth=methds[m]) c<- cutree(h,k) s<- silhouette(c,d) avgS[k-1,m]=mean(s[,3]) } } avgS