model equation:
y = H0_1 * (1 - exp(- (Tmax / beta) ^ theta)) + c
Hello, What I'm trying to do is plot an exponential best-fit curve to the data. I'm trying to make my first shiny app with a slider input for a number of bins to get the starting values. However, when I run the code it doesn't show any graph. The code:
x <- Tmax <- 443, 454, 451, 438, 451, 452, 453, 454, 453, 445, 449, 449, 454
y <- HI <- 43, 62, 63, 95, 105, 117.51, 119.07, 122, 122, 125, 131.8, 137, 139
#save this script as app.R
library(shiny)
library(ggplot2)
ui <- fluidPage(
Application title
titlePanel("Exponential Equation App"),
Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput(inputId = "H0_1",label = "H0_1:",
min = 100,max = 1000,value = 100, step = 0.5),
sliderInput(inputId = "beta",label = "beta",
min = 300,max = 600,value = 300, step = 0.5),
sliderInput(inputId = "theta",label = "theta",
min = -200,max = -1,value = -5, step = 1),
sliderInput(inputId = "c",label = "c",
min = 0,max = 100,value = 0, step = 1)
),
mainPanel(
plotOutput("lineplot")
)
)
)
server <- function(input, output) {
output$lineplot <- renderPlot({
x <- seq(from = 427, to = 458, by = 1)
y <- H0_1 * (1 - exp(- (Tmax / beta) ^ theta)) + c
plot(x,y, col="red", lwd = 3, type = "l")
lines(y~For_RStudio$Tmax, col="blue", lwd=3)
legend("topleft",c("real data","constructed"),
col=c("blue","red"), lwd=3)
})
}
shinyApp(ui = ui, server = server)
it seems to me that you are not using any of your defined slider inputs in your server function. Try using them with
input$H0_1instead of just writingH0_1.This means, this line in your server logic
should be
Edit 1
Here is an app that is at least running. I am clueless of the goal that your app should achieve, aka I don't know how you choose the start values for exp. fit equation. But from the technical side, this is a running app and you can modify it in a way, that makes it work.
what I did:
x_real,y_realfor observed data andx_constr,y_constrfor constructed data.,and around=for legibility and because it is good tone