# server.R
 palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
  "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
# load data
 

server <- function(input, output, session) {

  # Combine the selected variables into a new data frame
  selectedData <- reactive({
    ## Generate random samples from num Gaussians specified by the user
    prova = input$Sample
    aux = seq(1:length(nameX))
    sel = aux[nameX==prova]
    selectedData = data.frame(X[[sel,1]])
  })

  clusters <- reactive({
    Mclust(selectedData())
  })

  output$plot1 <- renderPlot({
    plot(selectedData(), col=clusters()$classification, pch = 20, cex = 3)
    points(t(clusters()$parameters$mean), pch = 4, cex = 4, lwd = 4)
  })
}