R Shiny non-numeric argument -


i started using shiny , there first problem when run code:

shiny server.r

library(shiny)  shinyserver( function(input, output){   asset <- reactive(input$asset) weight1 <- 0.3 weight2 <- 1-weight1  sum1 <- asset*weight1 

shiny ui.r:

library(shiny)  shinyui(fluidpage(  titlepanel(title = "programm"), sidebarlayout( sidebarpanel(("asset 1:"),            numericinput("asset:", "asset1:", 0, min=0, max=1000000)), mainpanel(("xyz"),             )     )  )) 

the error says: non-numeric argument binary operator. there possibility numeric values out of reactive function? thank help!

side note: code sadly not reproducible. better code make more answer

the problem asset reactive object. hence can not multiply in line sum1 <- asset*weight1. should instead

sum1 <- reactive({asset()*weight1}) 

the total code can like

shiny::shinyapp(shinyui(fluidpage(      titlepanel(title = "programm"),     sidebarlayout(         sidebarpanel(numericinput("asset", "asset1:", 0, min=0, max=1000000)),         mainpanel(  textoutput("text1"))      )    )),   shinyserver(     function(input, output){         asset <- reactive(input$asset)         weight1 <- 0.3         weight2 <- 1-weight1         output$text1 <- reactive({asset()*weight1})      })) 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -