Janyary 22, 2021

Shiny Web Application in R

The app I present was developed in RStudio, using Shiny which is a very useful library for developing and deploying web applications.

Shiny Web Application in R

The app is a representation of a machine learning algorithm, namely KMeans, which is used to classify data.

Shiny Web Application in R

A code extract is shown below, where the ui function is defined:

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(pageWithSidebar(
        headerPanel('Iris k-means clustering'),
        sidebarPanel(
            selectInput('xcol', 'X Variable', names(iris)),
            selectInput('ycol', 'Y Variable', names(iris), selected = names(iris)[[2]]),
            numericInput('clusters', 'Cluster count', 3, min = 1, max = 9)
        ),
        mainPanel(
            plotOutput('plot1')
        )
    )
)

Shiny Web Application in R

The app is available at this url: https://degrest.shinyapps.io/shiny/.

And as shown in the picture below, after selecting the type of data and the number of clusters we can see the algorithm output.