Advertisement
Guest User

Untitled

a guest
Jul 12th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.56 KB | None | 0 0
  1. ```{r sillhouette-plots, echo=FALSE, message=FALSE}
  2. library(shiny)
  3. library(cluster)
  4. library(dplyr)
  5.  
  6. ui <- fluidPage(
  7.   wellPanel(
  8.     fluidRow(
  9.       column(4, offset=4,
  10.              numericInput("k", "Number of clusters", min = 2, max = 8, value = 3)
  11.       ))),
  12.   plotOutput("sillhouettes")
  13. )
  14.  
  15. server <- function(input, output, session) {
  16.   output$sillhouettes <- renderPlot({
  17.     sill.model <- pam(mtcars[-1], k = input$k)
  18.     plot(mtcars, which.plots = 2, main = paste0("Sillhouette plot for data, k = ", input$k))
  19.   })
  20. }
  21.  
  22. shinyApp(ui, server)
  23. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement