-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
76 lines (67 loc) · 2.27 KB
/
Copy pathserver.R
File metadata and controls
76 lines (67 loc) · 2.27 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
library(shiny)
# Define server logic for random distribution application
shinyServer(function(input, output) {
# Reactive expression to generate the requested distribution.
# This is called whenever the inputs change. The output
# functions defined below then all use the value computed from
# this expression
data <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header=input$header, sep=input$sep,
quote=input$quote)
})
output$fileuploaded <-reactive({
inFile <- input$file1
return(!is.null(inFile))
})
outputOptions(output,"fileuploaded",suspendWhenHidden=FALSE)
# Generate a plot of the data. Also uses the inputs to build
# the plot label. Note that the dependencies on both the inputs
# and the data reactive expression are both tracked, and
# all expressions are called in the sequence implied by the
# dependency graph
output$boxplot <- renderPlot({
boxplot(data.frame(data())[c("V2","V3","V4","V5","V6")])
lines(tapply(data.frame(data()[["V3"]]),"V3",mean), col='blue', type='b') #加上平均值
})
output$plot2 <- renderPlot({
hist(data.frame(data())[["V2"]])
})
output$plot3 <- renderPlot({
hist(data.frame(data())[["V3"]])
})
output$plot4 <- renderPlot({
hist(data.frame(data())[["V4"]])
})
output$plot5 <- renderPlot({
hist(data.frame(data())[["V5"]])
})
output$plot6 <- renderPlot({
hist(data.frame(data())[["V6"]])
})
output$pairs <- renderPlot({
pairs(data.frame(data())[c("V2","V3","V4","V5","V6")])
})
output$sum <- renderPrint({
rowSums(as.matrix(sapply(data.frame(data())[c("V2","V3","V4","V5","V6")],as.numeric)))
})
output$sumhist <- renderPlot({
hist(rowSums(as.matrix(sapply(data.frame(data())[c("V2","V3","V4","V5","V6")],as.numeric))))
})
output$sumboxplot <- renderPlot({
boxplot(rowSums(as.matrix(sapply(data.frame(data())[c("V2","V3","V4","V5","V6")],as.numeric))))
})
output$cor <- renderPrint({
cor(data.frame(data())[c("V2","V3","V4","V5","V6")])
})
# Generate a summary of the data
output$summary <- renderPrint({
summary(data())
})
# Generate an HTML table view of the data
output$table <- renderTable({
data.frame(data())
})
})