-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
43 lines (32 loc) · 957 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
34
35
36
37
38
39
40
41
42
43
library(shiny)
library(datasets)
mpgData <- mtcars
mpgData$am <- factor(mpgData$am, labels = c("Automatic", "Manual"))
shinyServer(function(input, output) {
formulaText <- reactive({
paste("mpg ~", input$variable)
})
formulaTextPoint <- reactive({
paste("mpg ~", "as.integer(", input$variable, ")")
})
fit <- reactive({
lm(as.formula(formulaTextPoint()), data=mpgData)
})
output$caption <- renderText({
formulaText()
})
output$mpgBoxPlot <- renderPlot({
boxplot(as.formula(formulaText()),
data = mpgData,
outline = input$outliers)
})
output$fit <- renderPrint({
summary(fit())
})
output$mpgPlot <- renderPlot({
with(mpgData, {
plot(as.formula(formulaTextPoint()))
abline(fit(), col=2)
})
})
})