Error in *: non-numeric argument to binary operator

Hi, I'm new to R shiny, and running into a few problems. Basically, I'm trying to let the user provide values for 3 inputs, and then using those values as well as additional constants, make calculations. My code is below:

ui <- fluidPage(
    
    # App title ----
    titlePanel("Nitrogen Budget Calculator"),
    textInput("Yield", "Desired Yield [cwt/ac]"),
    textInput("Fert", "Fertilizer Applied [lb/ac]"),
    textInput("Inches_Applied", "Inches of Irrigation Applied throughout growing season"),
    actionButton("action", "Calculate N Leaching")
    )
Irrigation_N = 18 
Precip_N = 0 
Inches_Precip = 32 
Conversion_factor = .226  
N_content = .4 
Man = 0 
Symbiotic_N_Fixation = 0 
Precip = 5 
Dry_Deposition = 5 
Crop_Seed = 0 
Nonsymbiotic_Fixation = 3 
server <- function(input, output) {
    observeEvent(input$action,{
    vals<-reactiveValues()
    observe({
        vals$Yield = input$Yield
        vals$Inches_Applied = input$Inches_Applied
        vals$Fert = input$Fert
        vals$Irr = Irrigation_N*vals$Inches_Applied*.226  
        vals$TotalInputs = vals$Fert + Man + Symbiotic_N_Fixation + vals$Irr + Precip + Dry_Deposition
        + Crop_Seed + Nonsymbiotic_Fixation
    })
    })
    
    
    text_calc<- renderText({ 
        #Leachable_N =Total_Inputs-Total_Outputs-Total_Storage_Change
        paste("Leachable N =",vals$TotalInputs)
    })

vals$Inches_applied is text format.

change them as numerical value like as.numerical will work.

if you want the users to enter numbers its more typical to provide a numericInput than a textInput
https://shiny.rstudio.com/reference/shiny/1.4.0/numericInput.html

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