i am doing some simple calculations using R and presenting them in shiny where some variables of the calculations should be inserted by the user.
in the ui <-
I have
Q1 <- numericInput("myInput1", "question1", value= 1)
I want to extract the Q1 numeric integer value which in this case number 1 and use it in another equation, for example:
B= Q1+1
the Q1 is a numericInput inside shiny ui and a user could change the value by typing a different value ex: number 2 . the new value should be used to calculate Q1 value which is 2 + 1 = 3 the value of B
when I run the app, I face this error message:
Error in Q1 + 1 : non-numeric argument to binary operator
thank you in advance for looking at my problem and appreciate your help
thanks
Ahmed Ali
PhD candidate
Chung Ang University
The value of the numericInput is part of the input list, You refer to it with its inputId, myInput1, as input$myInput1. Here is a very simple example. Note that the calculations are done in the server section of the app.
thanks alot for your quick reply,
so in the below example:
in ui<-
user insert "myInput1" value then
in server<- B = input$myInput1+2
my questions is: how can I use the "B" value as integer in further integer calculations. for example: I want to use B+2= C then C+2=D finally print D as final result in shiny?
concept in shiny: user insert myInput1 value and get the result of D