1

Here's a long-shot question. The below code allows the user to build and alter a scaled-logarithmic curve by altering its 4 parameters, via slider inputs. I'd like to reverse the process, so the user clicks/drags the plot line and a new "exponential" curve parameter is backed into. How to do this in R Shiny?

Later, after figuring out how to derive the exponential parameter, I'll try backing into some of the other curve parameters too.

This image illustrates what I'm trying to do:

enter image description here

Code:

library(shiny)

ui <- fluidPage(
  
  sliderInput('periods','Nbr of periods:',min=0,max=36,value=24),
  sliderInput('start','Start value:',min=0,max=1,value=0.15),
  sliderInput('end','End value:',min=0,max=1,value=0.70),
  sliderInput('exponential','Exponential:',min=-100,max=100,value=10),
  plotOutput('plot')
  
)

server <- function(input, output, session) {
  
  data <- reactive({
    data.frame(
      Periods = c(0:input$periods),
      ScaledLog = c(
        (input$start-input$end) *
        (exp(-input$exponential/100*(0:input$periods))-
        exp(-input$exponential/100*input$periods)*(0:input$periods)/input$periods)) +
        input$end
    )
  })
  
  output$plot <- renderPlot(plot(data(),type='l',col='blue',lwd=5))
  
}

shinyApp(ui,server)

0 Answers0