Is there a function in R Studio to create an interactive map using NYC zip codes?

I have a dataset that has NYC Zip codes, and in a different dataset, I have lat and long codes. I am aware that I can use Leaflet to create an interactive but when I try run it on the 167K rows of data, R Studio freezes and struggles to load the data. I done that using the below code

leaflet(nyctest) %>%
  addTiles() %>%
  addMarkers(lat = ~Latitude, lng = ~Longitude

My question, is there a way to create an interactive map using the New York City Zip codes?

Example of the zip codes data:

11001, 11021, 11050, 11101, 11102, 11103, 11104, 11105

Thanks in advance!

A quick note about cross posting:

From: FAQ: Is it OK if I cross-post?

Posting the same question to multiple forums at the same time is often considered impolite. We don't completely ban such cross-posting, but we ask you to think hard before you do it and to follow some rules.

:mantelpiece_clock: Cross-post sparingly
Rather than post the same thing here and elsewhere from the get-go, post in one place at a time. Let enough time go by (think days, not hours) before you take your question somewhere else. Sometimes people at another site may suggest you post here if your question doesn't fit within the scope of the other site.

:link: Always link to your other posts, and update everywhere with any solutions
No matter what your reason for cross-posting is, when you post here please be sure to link to your related post on the other site and keep both ends updated with any solution.

:recycle: Don't just dump a link to your post on another help site
If you posted elsewhere but didn't find a solution, please don't just drop a link to that original post here. A bare link post is missing the details that make it useful and discoverable to people with similar problems in the future. It is also unlikely to entice any potential helpers to click through.

As mentioned in your stack overflow post, here's an example of how to display data like that in a shiny app,

Shiny app, SuperZip Explorer example app

Code;

If you're machine is freezing up, you might first build it with a subset of zip-codes.

There seems to be something missing in your question: NYC has much fewer ZIP codes than 167K.

  • Are you trying to display the ZIP codes as polygons?
  • Are you trying to display the 167K data items as points? (this might not be the best idea)
  • Are you trying to aggregate the 167K observations per ZIP code, and then display the result?

These are different problems – all doable in R & RStudio – but require different approaches.

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