-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.R
More file actions
46 lines (43 loc) · 1.26 KB
/
server.R
File metadata and controls
46 lines (43 loc) · 1.26 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
library(shiny)
source('function.R', local = TRUE)
# Define server logic required to generate and plot a random distribution
shinyServer(function(input, output) {
mydataL <- reactive({
Names<-c("Data","Km")
if(input$action == 0)
return(mydataRead())
else
isolate({
orig.date<-as.Date(input$D, origin = "1900-01-01")
new.date<-as.character(format(orig.date, format=c("%d/%m/%Y")))
newrow<-list(new.date,input$W)
if (input$sel == "ins")
newRow(mydataRead(),newrow,Names)
if (input$sel == "add")
insertRow(mydataRead(),newrow,input$R)
if (input$sel == "cha")
changeRow(mydataRead(),newrow,input$R)
if (input$sel == "del-las")
deleteLastRow(mydataRead())
if (input$sel == "del-a")
deleteARow(mydataRead(),input$R)
di<-mydataRead()
return(di)
})
})
output$km<- renderTable({
mydataL()
})
output$summary<- renderPrint({
data_ren<-mydataL()[2]
summary(data_ren)
})
output$plot<- renderPlot({
data_ren<-mydataL()[,2]
data_length<-length(data_ren)
seq_length<-seq(1,data_length, by=1)
xLab<-mydataL()[,1]
plot(seq_length, data_ren, type="l", col="red", xaxt = "n", xlab="Day", ylab="Km")
axis(1, at=1:data_length, labels=xLab)
})
})