FreddyHernandez commited on
Commit
7d99366
verified
1 Parent(s): d2f9349

Create server.R

Browse files
Files changed (1) hide show
  1. server.R +23 -0
server.R ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function(input, output, session) {
2
+
3
+ # Combine the selected variables into a new data frame
4
+ selectedData <- reactive({
5
+ iris[, c(input$xcol, input$ycol)]
6
+ })
7
+
8
+ clusters <- reactive({
9
+ kmeans(selectedData(), input$clusters)
10
+ })
11
+
12
+ output$plot1 <- renderPlot({
13
+ palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
14
+ "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
15
+
16
+ par(mar = c(5.1, 4.1, 0, 1))
17
+ plot(selectedData(),
18
+ col = clusters()$cluster,
19
+ pch = 20, cex = 3)
20
+ points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
21
+ })
22
+
23
+ }