0
votes

I think this should be a pretty easy fix.

I created a simple program in R that plots an eBird user's data on a leaflet map, all they have to do is upload the csv of their eBird data.

My code is included here: MY CODE

I have the app all laid out, but am struggling with using the input from fileInput(). Currently, when I hit "Run App", a window opens for a split second, then closes and throws an error. I included the error at the end of my code at the above link.

You can check out sample data here: SAMPLE DATA

How should I be formatting the file input from the ui for the server to use?

myData = reactive(input$MyEBirdData_in)
1

1 Answers

0
votes

myData is a reactive variable and further on in the code you need to treat it as such.

So for example this line:

df0 = data.frame(myData$Submission.ID, myData$Latitude, myData$Longitude)

would need to be:

df0 = reactive({data.frame(myData()$Submission.ID, myData()$Latitude, myData()$Longitude)
})

And so on through the app. rather than wrapping each individual statement though you could put everything in the render leaflet function as a wrapper:

output$myMap = renderLeaflet({
  df0 = data.frame(myData()$Submission.ID, myData()$Latitude, myData()$Longitude)
  df = unique(df0)
  names(df)[2] = 'latitude'
  names(df)[3] = 'longitude'

  circleIcon = makeIcon(
    iconUrl = "http://www.clker.com/cliparts/Q/l/D/8/k/m/red-circle-icon-md.png",
    iconWidth = 7, iconHeight = 7)

  eBirdMap = leaflet(data = df) %>% addProviderTiles(providers$CartoDB.Positron) %>%
    addMarkers(icon = circleIcon)

  eBirdMap
})

EDIT: forget to reference reactive variables as variable().