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
| library(shiny)
shinyServer(function(input, output) {
mydata <- reactive({
inc<-input$inc
x<-seq(0,input$x0,inc)
a1<-input$a1
b1<-input$b1
h1<-(a1)*x+b1
h2<-(1.4/27^1.4)*x^0.4
#replace negatives numbers by 0+ to set a level to not start at 0
eps<-0.000000001
h1[h1<=eps]<-eps
h2[h2<=eps]<-eps
list(x=x,h1=h1,h2=h2)
})
output$graph1<-renderPlot({
data<-mydata()
p<-plot(0,0,type="n",xlab="x",ylab="y",xlim=range(data$x),ylim=c(0,max(data$h1+data$h2)))
lines(data$x,data$h1,col="red")
lines(data$x,data$h2,col="green")
lines(data$x,data$h1+data$h2,col="black")
legend("topleft",c("event 1","event 2","total"),col=c("red","green","black"),lty=1)
print(p)
})
}) |
Partager