How i can use a graphically switch in order to change the value of variable in R?

HI!
My name is Marco, i have a little problem with R. I need to make an add on for an existing program. For this i need to change a variable and look what this change do in a real time graph. I will give to you an example.

EXAMPLE IMAGE

I have a function y=m*x^g+q, i have some variable fixed, and other variable that the user can put or change manually, and i have the variable g that i need to monitorate while it change. When, with the mouse, the user switch the number of G the graph must change in live wiev.

Can you tell me how i can do that with R? Even if i can do it with other languages but even for R.

Thank you so much!

library(shiny)

ui <- fluidPage(
  sliderInput(inputId = "slider_g",
              label="slide me",
              min=0,
              max=10,
              value=5),
  plotOutput(outputId = "plot")
)

server <- function(input, output, session) {
  
  output$plot <- renderPlot({
    
    x <- 0:10
    y <- x ^ req(input$slider_g)
    plot(x,y)
    
  })
  
}

shinyApp(ui, server)

study shiny here:
https://shiny.rstudio.com/tutorial/

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.