-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
33 lines (27 loc) · 1006 Bytes
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(caret)
library(ggplot2)
library(shiny)
model <- train(iris[1:4], iris$Species)
shinyServer(function(input, output) {
output$scatterPlot <- renderPlot({
df <- data.frame(Sepal.Length = input$sepalLength,
Sepal.Width = input$sepalWidth,
Petal.Length = input$petalLength,
Petal.Width = input$petalWidth)
df <- cbind(df, Species = predict(model, df))
ggplot(iris, aes_string(x = input$xfield, y = input$yfield, color = "Species")) +
geom_point() +
labs(x = sub("\\.", " " , input$xfield),
y = sub("\\.", " " , input$yfield)) +
scale_color_brewer(palette = input$palette) +
geom_point(data = df, size = 8, shape = 4)
})
})