2

I am trying to make a R shiny APP that runs an executable program. I am new to shiny so sorry if this question should be obvious but I have looked and can't find anything that addresses my problem. Everything runs fine until the call to function runhysplit(). My question is: why do I get the following error when running the code below:

"Warning: Unhandled error in observer: object 'input' not found observeEvent(input$runHys)."

    library(opentraj)
    library(plyr)
    library(shiny)
    library(shinydashboard)
    source('/root/Desktop/HysplitMatcher/runhysplit.R')
    ui <- {dashboardPage(
    dashboardHeader(title = "HYSPLIT TRAJECTORY MATCHING TOOL", titleWidth=450),
    dashboardSidebar(
                  sidebarMenu(
                              menuItem("Multiple Trajectories", tabName =   "dashboard", icon = icon("dashboard")),
                              menuItem("Widgets", tabName = "widgets", icon   = icon("th"))

                    )

    ), 
  dashboardBody(

              numericInput(inputId="hour.interval", label = "Hour Interval", value = 1),
              numericInput(inputId="hours", label = "Total Run Time (hours)", value = -72), 
              selectInput(inputId ="metdata", label="Meteorology Data:", choices=c("North American Model (NAM) 00Z", "North American Model (NAM) 12Z"), selected = NULL, width = NULL),
              selectInput(inputId ="location", label="Location", choices=c("Evansville", "Indianapolis Metro", "Gary", "Standiford Field (Louisville)", "South Bend")),
              numericInput(inputId="height", label="Height AGL", value=100),
              dateRangeInput(inputId="dates", label="Enter a date range (yyyy-mm-dd)", format="yyyy-mm-dd", separator = " to "),
              numericInput(inputId="start.hour", label="Enter a staring time (hh:mm)", value = ""),
              numericInput(inputId ="end.hour", label="Enter an ending time (hh:mm)", value = ""),
                      actionButton(inputId ="runHys", label ="RunHysplit"),
                      textOutput("dates")
  #                  submitButton("Get Trajectories")
              )
        )
    }


    server <- function(input, output) {

    results <- observeEvent(input$runHys, {
    lat <- c(37.9772, 39.7910, 41.5956, 38.1742, 41.6725)  
    lon <- c(-87.5506, -86.1480, -87.3453, -85.7364, -86.2553)
    locations <- c("Evansville", "Indianapolis Metro", "Gary", "Standiford             Field (Louisville)", "South Bend")
    latlonlook <- data.frame(lat,lon,locations)
    latlonlook <- subset(latlonlook, locations == input$location)
    lat <- latlonlook$lat
    lon <- latlonlook$lon
    cat(lat)
    cat("\n")
    cat(lon)
    dateseq <- seq(from=input$dates[1], to=input$dates[2], by=1)
    cat("\n")
    cat(dateseq)
    cat("\n")
    cat(input$hour.interval)
    cat("\n")
    cat(input$metdata)
 runhysplit(lat=lat, lon=lon, hour.interval=input$hour.interval, name="hysplit_fore",start.hour=input$start.hour, end.hour=input$end.hour, met="/root/Desktop/HysplitMatcher/",out="/root/Desktop/HysplitMatcher/", hours=input$hours, height=input$height, hy.path="/root/hysplit/trunk/", ID=1, dates=dateseq, metdata=input$metdata) 
})
}

shinyApp(ui, server)
6
  • if you change it to server<-function(input,output,session){ does that help? Commented Sep 10, 2015 at 16:46
  • Hi, John. No, returns the same error. Commented Sep 10, 2015 at 16:51
  • Probably you put the brackets that you shouldn't: ui <- dashboardPage(...) Commented Sep 10, 2015 at 16:59
  • I removed the brackets. No luck. Commented Sep 10, 2015 at 17:10
  • please provide the code for runhysplit Commented Sep 11, 2015 at 7:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.