简体   繁体   中英

How to change the value of global variable in r shiny(increment)

I have written a code for my application where I have used Global variable( lvl in my case). But it's not changing when my condition is being met and it's proceeding on another condition.

server<- function(input, output, session)
{
  lvl <- 1

    switch(lvl,

           # Conditions for Level 1

           if ("A CONDITION") {
             Statement

             lvl <- lvl + 1
           }
           else
           {
             invalidInput()
           }
else if{
}

Try below code:

server<- function(input, output, session)
{
    i <- 1
    lvl <- reactiveVal()
    lvl(i)

    switch(lvl,

           # Conditions for Level 1

           if ("A CONDITION") {
             Statement

             lvl(lvl + 1)
           }
           else
           {
             invalidInput()
           }
else if{
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM