Shiny Application and Reproducible Pitch

Hemantakumar Hegde
28-02-2020

Simple shiny application demonstrating interactivity

You can open the shiny application here https://equalstrue.shinyapps.io/CourseProject/.

  • This uses the old and familar dataset iris
  • It tries to cluster the data using the k-means clustering algorithm
  • Using the slider on the left you can select the number of clusters you want to create

Following code generates a scatter plot with colors representing clusters

library(ggplot2)
data("iris")
set.seed(5000)
num_cluster<- 3
        irisCluster <- kmeans(iris[, 0:3], num_cluster, nstart = 20)
        scatter <- ggplot(data=iris, aes(x = Sepal.Length, y = Sepal.Width)) 
        scatter <- scatter + geom_point(aes(color=as.factor( irisCluster$cluster), shape=Species)) +
            xlab("Sepal Length") +  ylab("Sepal Width") +
            ggtitle("Sepal Length-Width")

# plot on the next slide >>

Plot generated with 3 clusters

plot of chunk unnamed-chunk-2

  • There are actually 3 species setosa, versicolor, and verginica and are denoted by shapes
  • We can see that selecting 3 clusters will make the clusters approximately match the species

Thank you