First shiny app - error message - missing argument


#1

I'm working on my first shiny app. It's a simple line plot. I'm getting an error message on my selectinput line in the server.r file. What argument am I missing?

(ui.r)

shinyUI(fluidPage(
  
  # Application title
  titlePanel("US Violent Crime rate per 100,000"),
  
  # Sidebar with a Panel input
  sidebarLayout(
    sidebarPanel(
      selectInput("crime", "Please Select Crime Type", choices=c("All", "Murder", "Rape", "Robbery", "Assault")),
    ),
    
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("Plot")
    )
  )
))

(server.r)

data<- read.csv("FBI.csv"); ##attach(data);

library (ggplot2);
 
  ShinyServer(function(input, output){ 
  
  output$Plot <- renderPlot({
    ggplot(data, aes(Year, input$crime)) + geom_line() + geom_point()
  })
})

getting error

Listening on http://127.0.0.1:4812
Warning: Error in tag: argument is missing, with no default
Stack trace (innermost first):
    55: tag
    54: tags$form
    53: tag
    52: tags$div
    51: div
    50: sidebarPanel
    49: sidebarLayout
    48: tag
    47: tags$div
    46: div
    45: tagList
    44: attachDependencies
    43: bootstrapPage
    42: fluidPage
    41: shinyUI
     1: runApp

#2

You should remove the , at the end.


#3

Please format the code properly for readability. If you can post your data too it would be easier for reproducing the error. Take a look at my post, where I've uploaded the data on web, so that anyone running my script can get the data easily, if needed. Also, could you try making a reprex ?

Try the steps on this page https://rstudio.github.io/leaflet/


#4

Thanks. That got rid of the error message. Thanks. Now I just have to get my output to me nonzero and my label to be something other than "input$crime".

I'll work on it for a while longer. I appreciate the help. I've got some things to add and I'll eventually go back to the original, much larger, file that I got from the FBI site.

Year All Murder Rape Robbery Assault
1994 713.6 9 39.3 237.8 427.6
1995 684.5 8.2 37.1 220.9 418.3
1996 636.6 7.4 36.3 201.9 391
1997 611 6.8 35.9 186.2 382.1
1998 567.6 6.3 34.5 165.5 361.4
1999 523 5.7 32.8 150.1 334.3
2000 506.5 5.5 32 145 324
2001 504.5 5.6 31.8 148.5 318.6
2002 494.4 5.6 33.1 146.1 309.5
2003 475.8 5.7 32.3 142.5 295.4
2004 463.2 5.5 32.4 136.7 288.6
2005 469 5.6 31.8 140.8 290.8
2006 479.3 5.8 31.6 150 292
2007 471.8 5.7 30.6 148.3 287.2
2008 458.6 5.4 29.8 145.9 277.5
2009 431.9 5 29.1 133.1 264.7
2010 404.5 4.8 27.7 119.3 252.8
2011 387.1 4.7 27 113.9 241.5
2012 387.8 4.7 27.1 113.1 242.8
2013 367.9 4.5 25.2 109.1 229.1

#5

Thank you. I'm installing it now.