R Maps: Beautiful Interactive Choropleth & Scatter Maps with Plotly

  Рет қаралды 31,019

Dataslice

Dataslice

Күн бұрын

R Maps: Beautiful Interactive Choropleth & Scatter Maps with Plotly
Timeline
0:00 Intro
0:28 Reading in data (Choropleth)
1:44 Building base graph (Choropleth)
3:06 Functional & aesthetic changes (Choropleth)
8:02 Reading in data (Scatter map)
8:02 Building Base graph (Scatter map)
9:30 Functional & aesthetic changes (Scatter map)
11:50 Further reading
Learn how to make beautiful interactive maps in R in just a few minutes! Plotly isn't always the best mapping solution for some problems, but overall, it can function really well.
Code: github.com/abhimotgi/dataslic...
Plotly maps documentation:
plotly.com/r/choropleth-maps/
plotly.com/r/scatter-plots-on...
US Minimum Wage by States: www.kaggle.com/lislejoem/us-m...
US States & Codes: worldpopulationreview.com/sta...
UFO Sightings: www.kaggle.com/NUFORC/ufo-sig...

Пікірлер: 71
@mkklindhardt
@mkklindhardt 2 жыл бұрын
Thank you! Especially the static map using plotly was super helpful.
@NE0KRATOS
@NE0KRATOS 3 жыл бұрын
Thank you so much! I feel so lucky to have found your channel. The quality is top notch as always, and I hope it will grow as it deserves! Cannot wait to see more of your videos!
@dataslice
@dataslice 3 жыл бұрын
Thank you!
@jessicah3782
@jessicah3782 2 жыл бұрын
I love how fast and smooth you teach. Everything is so fluid and clear. Thanks!
@UCKszbcV
@UCKszbcV 2 жыл бұрын
So fast I needed to activate x0.75 reproduction speed
@ibrahimadiallo7444
@ibrahimadiallo7444 3 жыл бұрын
Definetly earned my subscription 😌❤
@naterush5019
@naterush5019 3 жыл бұрын
This is so well done and informative!
@dataslice
@dataslice 3 жыл бұрын
Thanks so much!
@MMansouri
@MMansouri 3 жыл бұрын
Another great video!
@jannatulferdous8846
@jannatulferdous8846 3 жыл бұрын
You are awesome. I was struggling to plot the US map for Election funding by states. I was about to go crazy. Your code has saved my sanity.
@cheettaah
@cheettaah 3 жыл бұрын
Great video. Bravo!
@Purplehairedpimp
@Purplehairedpimp 3 жыл бұрын
I really like your presentation. Surprised it doesn't have more views; it's well done. However I'm still on the hunt for a solution to make a combined Mapbox(OpenStreetMaps) + Chloropleth + Scatterplot map, using ploty/R/Shiny that is.
@alexsanjose
@alexsanjose 3 жыл бұрын
Yet another amazing video. I've been working on R for 10 years now, but I always learn something new and cool in your videos!
@dataslice
@dataslice 3 жыл бұрын
That’s great to hear, thanks!
@simba8026
@simba8026 3 жыл бұрын
thank you. your videos are great
@dataslice
@dataslice 3 жыл бұрын
Glad you like them!
@sapiain16
@sapiain16 3 жыл бұрын
Thank you!!
@dataslice
@dataslice 3 жыл бұрын
No worries!
@bigg1esworth
@bigg1esworth 3 жыл бұрын
Cool vid
@melandsant
@melandsant 3 жыл бұрын
thank you for great lesson. I want to ask a question about how to change legend's range?
@terraflops
@terraflops 3 жыл бұрын
Thanks for your video, I suspect you are the same person that's behind "X software in 100 seconds" videos (sound the same). // I had to pass in a x and y for the ufos_graphs function, and had to give y= ~ufos$latitude, x= ~ufos$longitude in order for this to work. // new subscriber!
@tobih.4491
@tobih.4491 2 жыл бұрын
Thanks a lot, that is super useful! Can I ask one thing though: I would like to do the same thing for the German states (Bundesländer) and played around quite a bit with adjusting the locationmode. However, what I get at the end is always a map of the entire world, without any borders (be it country or state borders) whatsoever. Does anyone know how to replace the locationmode accordingly? That would be wonderful!
@BugsDavid
@BugsDavid Жыл бұрын
For the ones not managing to get the code right in the first example with the minimum wage data. For the inner_join command type it like: inner_join(states, by = c("State" = "state")). The rest as in the video. Greetings !
@ibrahimadieye2258
@ibrahimadieye2258 3 жыл бұрын
This is an awesome video! Thank you. I have one question. Is there a way to show the abbreviation on each state (as the state label) in addition to the hover window?
@dataslice
@dataslice 3 жыл бұрын
I believe you need to add a scattergeo trace as a layer to the map. There's some documentation here about it plotly.com/r/reference/#scattergeo
@CAVescera
@CAVescera 3 жыл бұрын
You are so awesome at this. So easy going, and easy to follow. One thing- I want to make a state/county map showing employee locations. I have FIPS, State, County, and the count of employees in each FIPS. I can get that working, but is there an easy way to create a dropdown by State, and another by county? I can't find this anywhere, and everywhere I DO look, the programmers are far beyond my skill level. Thanks!
@dataslice
@dataslice 3 жыл бұрын
I believe you can add drop downs the way you want to, maybe try following this documentation plotly.com/r/dropdowns/ Also if you’re not tied to R I’d recommend checking out Tableau public if you want something a bit more user friendly
@gabriellamartinez7985
@gabriellamartinez7985 Жыл бұрын
Thank you for your video! It has really helped me get my assignment started. QUESTION: Is there a way to add a drop down filter for an additional categorical column. For example, lets say there was an additional column for Gender where there is then multiple values for the Wage column in the same year, how would we be able to filter to see the wage for each specific gender?
@22bears
@22bears Жыл бұрын
If i don't have a CSV of the abbreviation of my states, which kind of plot can I use instead?
@mm_007
@mm_007 2 жыл бұрын
Do you have an example how to plot r plotly chloropeth map for non-US states? I need to plot cities of canada with given latitude and longitude.
@murtazabadshah8747
@murtazabadshah8747 3 ай бұрын
Do you have a video on making a bargraph with a drop down filter?
@soumia117
@soumia117 2 жыл бұрын
Hi is there a way to only show Los Angeles County in plotly?
@frankjr3787
@frankjr3787 2 жыл бұрын
How would you plot the lats and longs over time
@jaroslavkotrba3548
@jaroslavkotrba3548 3 жыл бұрын
It is a nice video, however, wondering where there is a possibility to DISABLE zooming in the plot?
@filanor2416
@filanor2416 3 жыл бұрын
Excellent content on interactive mapping in R. I just only want to point out that link for the UFO Sightings dataset is incorrect. I wish you continued success and thank you..
@dataslice
@dataslice 3 жыл бұрын
Thanks for letting me know, I just fixed it!
@yobeaubaby
@yobeaubaby 3 жыл бұрын
Thank you 🤙
@haraldurkarlsson1147
@haraldurkarlsson1147 Жыл бұрын
Nice overall but I think plotly is a rather cumbersome and confusing way of going given all the other great packages that can do interactive maps. By the way there is a way to handle the state abbrevations without having to bring in another dataset namely the built-in package usdata : usdata::state2abbr(State). It leaves out Guam and Puerto Rico but that can be remedied with mutate statement ( mutate(state_abb = if_else(state == "Guam", "GU",state_abb), state_abb = if_else(state == "Puerto Rico", "PU", state_abb)). Thanks - we need more on mapping.
@victorog8249
@victorog8249 3 жыл бұрын
Thank you for the video! Do you know how to include the interactive "minwage_graph" into Overleaf/LaTeX?
@haraldurkarlsson1147
@haraldurkarlsson1147 Жыл бұрын
You can save the map (ggsave or something like that) and then bring it into LaTeX. Might be wise to scale it in R first. By the way there is a package for maps in LaTeX - relatively new and a bit tricky. It is called mercatormap. I needs python but can do some basic stuff without it in manual mode.
@debarghaguhaneogi8048
@debarghaguhaneogi8048 2 жыл бұрын
I was facing issues to set zmin and zmax, there is no change in the behaviour of z even after adding zmin and zmax, please help me out
@mirandaansell4434
@mirandaansell4434 3 жыл бұрын
Loved this! Is there any way of being able to knit the first map into HTML? :)
@dataslice
@dataslice 3 жыл бұрын
If you're trying to export the whole graph as an HTML to embed onto a page, you can use htmlwidgets::saveWidget(as_widget(graph), "graph.html") where graph is your plotly graph variable
@user-cz6il4oz4m
@user-cz6il4oz4m 6 ай бұрын
Is there a way to change the name of the frame? My map looks a little untidy because the frame variable has been pulled straight from the data frame, and i'd like to rename it to make it neater.
@purbashachowdhury2985
@purbashachowdhury2985 3 жыл бұрын
Hey! how to plot similar graph for Indian states? Plz give me ideas.
@ernestamoore4385
@ernestamoore4385 2 жыл бұрын
Where can we find the csv?
@popcornnakkini
@popcornnakkini 3 жыл бұрын
how to make it display in shiny app ? I've try my code. local is fine, but error display in my shiny app? can you help how to make it?
@paras338
@paras338 3 жыл бұрын
Hello, Awesome video! I just wanted to ask one question that if I want to create a similar choropleth map for Australian states and their crime rates, I am not able to display the data using the code. I tried changing the locationmode to 'australia', 'australia-states', 'Australia' and 'australian-states' and many other options but I am unable to create the same graph. Could you please guide me with what changes do I need to make for Australian states. (My data already has state abbreviations like VIC, NSW etc) Waiting for your response. Thanks
@dataslice
@dataslice 3 жыл бұрын
Thanks for your question! I've been trying to look into this but from the documentation, it looks like the only scopes supported are: ( "world" | "usa" | "europe" | "asia" | "africa" | "north america" | "south america" ). I'm wondering if you could set the scope to world and then also just have the map zoomed in or set to be looking at Australia and then disabling panning? I'll need to look into this more but let me know if that works
@paras338
@paras338 3 жыл бұрын
@@dataslice Thank you so much for your response. Yes, I also checked and found out that there is no support for Australian map and we need to plot it like the way you explained. Anyways, I will check for more alternatives and will update if I find something helpful. Cheers.
@somebodyoncetoldme2069
@somebodyoncetoldme2069 3 жыл бұрын
Hi, do you know how to make the size of the graph bigger in r markdown and bring the timescale slider closer to the graph?
@dataslice
@dataslice 3 жыл бұрын
I haven't played around with it, but it looks like you can modify the x and y position of the slider (some documentation here plotly.com/r/reference/layout/sliders/) and could set the graph size by passing in parameters for width and height in the layout() like here plotly.com/r/setting-graph-size/
@somebodyoncetoldme2069
@somebodyoncetoldme2069 3 жыл бұрын
@@dataslice thank you so much
@anissuraiya2370
@anissuraiya2370 Жыл бұрын
Thanks, for the video. I use this for another data I found. I post it in my blog and link your video too, is it okay?
@dataslice
@dataslice Жыл бұрын
Sure!
@babatundeolapeju1407
@babatundeolapeju1407 3 жыл бұрын
That was an interesting and amazing video, Dataslice. Great job! However, I kindly seek your help here. I wish to make a choropleth map by states on Nigeria land space but I only got a blank map of the world, unlike the result you got. I think something is wrong with the location mode I used. Hereunder is my code: crime_df = read_excel("/Users/user/Desktop/Crime Report 2017/Crime Report 2017.xlsx", sheet = "Sheet2") murder1 = (crime_df)%>% select(YEAR, CODE, MURDER) mur_graph = plot_geo(murder1, locationmode = "Nigeria-state", frame = ~YEAR) %>% add_trace(locations = ~CODE, z = ~MURDER, color = ~ MURDER) Kindly put me through, please.
@areeratsriprai3155
@areeratsriprai3155 2 жыл бұрын
how to export it to gif?
@ojas24singh25
@ojas24singh25 3 жыл бұрын
it says object not found
@rashawnhoward564
@rashawnhoward564 2 жыл бұрын
datasets::state.abr gives states abbreviations in r
@ojas24singh25
@ojas24singh25 3 жыл бұрын
for some reason im not able to use the select funtion. How do i solve it?
@dataslice
@dataslice 3 жыл бұрын
Have you installed and loaded in the dplyr package?
@ojas24singh25
@ojas24singh25 3 жыл бұрын
@@dataslice Now it says that my plotly and dplyr packages are masked for some reason. Also i cannot believe you have less than 500views on this. the video was amazing. Thank you for helping, i have a competition tomorrow and im trying to make the same kind of map for covid cases state and month wise.
@ojas24singh25
@ojas24singh25 3 жыл бұрын
the plotly package. is masked by ggplot2 and the dplyr is masked by stats.
@dataslice
@dataslice 3 жыл бұрын
​@@ojas24singh25 I haven't had this issue but from looking online, it looks like you need to 'reload' the package -- something like this? library(devtools) reload(inst("dplyr")). Not sure if that'll work, but good luck with the competition!
@tello9504
@tello9504 3 жыл бұрын
Any book that you recommend for R? I’m newwwbiee
@DiggyRasta
@DiggyRasta 3 жыл бұрын
I recommend starting with this book ( r4ds.had.co.nz/index.html ) and this package to practice ( swirlstats.com/students.html ). And here are some more books you can look into once you're more comfortable ( rstudio.com/resources/books/ ).
@tello9504
@tello9504 3 жыл бұрын
@@DiggyRasta wooow! Thank you, Sorie
@DiggyRasta
@DiggyRasta 3 жыл бұрын
@@tello9504 I got you bro
@tello9504
@tello9504 3 жыл бұрын
@@DiggyRasta 🥺🥺🥺 love you bro
@Downesy230
@Downesy230 3 жыл бұрын
Anyone done this in Python?
@timecode37
@timecode37 3 жыл бұрын
Haha, zmin
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 76 МЛН
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 20 МЛН
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 8 МЛН
Geospatial Map Visualizations in R
12:58
Business Science
Рет қаралды 25 М.
Linear Regression Plots in R
12:06
Dataslice
Рет қаралды 12 М.
Creating interactive maps in R
8:14
A&G Statworks
Рет қаралды 21 М.
R tutorial: Creating Maps and mapping data with ggplot2
10:30
Statistics Guides with Prof Paul Christiansen
Рет қаралды 105 М.
Plot Spatial Data / Shapefiles in R | Gun Violence in Chicago
6:39
Clowns abuse children#Short #Officer Rabbit #angel
00:51
兔子警官
Рет қаралды 76 МЛН