Apr 16, 2013

Plotting data over a map with R

After searching for a few hours on the web, I’ve been able to get my R code working and plot breast cancer data on a world map. It might not the best looking map possible (R graphics is incredible!), but I am happy with that for now.

To produce the map I used the “maps” package available through CRAN repository. And of course I needed longitude and latitude coordinates for each country, which I searched on the web and added to my original data set. Here are the steps I followed:


1) Load a .csv file containing lat/long coordinates for all countries

> countryCoord<- read.csv (“~/Rworkdir/data/countryCoord.csv”)

2) Add lat/long coordinates to my original breast cancer data set (dataset is called “gapCleaned”). To do this I used the function “merge”, specifying to merge the two data sets by the variable “country” (both the datasets have this variable in common), and used left outer join (here is a good explanation of merge command)

> mergedCleaned<- merge(gapCleaned, countryCoord, by=”country”, all.x=TRUE)

All right, now I have two new columns in my data set, indicating lat and long coordinates for each country :) Cool, next step is finally drawing a map with the data.

3) Draw a world map and tell R where to plot breast cancer data

> library(maps)

> map(“world”,col=”gray90”, fill=TRUE)

image


I size the breast cancer symbol according to breast cancer value for each country in my data set

> radius <- 3^sqrt (mergedCleaned$breastcancer)

Finally, I give R instructions to plot my breast cancer data over the world map

> symbols(mergedCleaned$lon, mergedCleaned$lat, bg = “blue”, fg = “red”, lwd = 1, circles = radius, inches = 0.175, add = TRUE)


                    New cases of breast cancer in the world, 2002

image


I am sure we can do prettier plots with R (I know there are other interesting packages suitable for this, such as ggplot), but I am happy for now. I’ve learned something new and been able to visualize and communicate data in a more effective way than just a scatterplot.

Conclusions:

Looking at the map, we can quickly identify the countries/areas with the highest number of breast cancer cases and hypothesize patterns. As reported on my last post, these are United States, New Zealand, Israel, Central/Northern Europe and in general highly developed economies rather than developing countries.

34 comments:

  1. Too that's exactly practically what i'll be doing later on. Now i am just actually seriously upbeat. I act like I only agreed to be put together. As being legitimate total, Training also offers you wide-ranging forces over the country's immigration law legal process of law. He takes on events along with solitary immigrants, While he performed here connected one mum to be coming via El Salvador. They be afraid of the exists including asylum hunters will are in danger if they are came back due in lands source..

    Every get to give cash flow but yet we make a {New Jordan Releases 2020} decision, And also just how we like to spend some money reads a good deal information on which are you're. One's own via shawls by hoda inthat would runners {Cheap MK Bags} during 2016 hinted at {New Yeezy Boost 350} the item about {Coach Outlet Clearance Sale} yourself: Plus level educational facilities together with social programs obtained falling apart, You're looking at to allocate specific tools to inspire hawaii legislature in orde

    ReplyDelete
  2. I do accept as true with all the ideas youĂ­ve offered in your post. They are very convincing and can definitely work. Men Fashion Brown Leather Long Coat

    ReplyDelete
  3. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Essay Editing Uk

    ReplyDelete
  4. There are many Coach Outlet Online in the market.
    The best place to secure that you are really getting an authentic Michael Kors Bags Outlet is from the authorized stores.
    One of the primary concerns when buying a new Michael Kors Purse Outlet is that of authenticity.
    If you are smart and want full value for your money, then there are some ways in which you can identify an original Coach Outlet Store Online.
    Remember, the MK Outlet never comes off, and never tears out.
    Probably the best way to find out if the Coach Bags Clearance is actually.
    Time to go online and get yourself a Coach Bags Outlet if you haven't already.
    Cheap Real Yeezys, a Nike new product launched recent years, is one of them.
    Actually, there are many stores stocking Cheap Yeezys.

    ReplyDelete
  5. website development services Seamlessly, developers are heading ahead to analyze and understand various programming languages

    ReplyDelete
  6. Thanks for sharing this.,
    Leanpitch provides crash course in Brain hacks using NLP everyone can use it wisely.
    NLP training

    Brain hacks with NLP

    ReplyDelete
  7. Thanks for sharing this.,
    Leanpitch provides crash course in Brain hacks using NLP everyone can use it wisely.
    NLP training

    Brain hacks with NLP

    ReplyDelete
  8. Likert Scale is a very useful visualization to present the survey results. Can you shed light which tools are best and easy to use to draw 5 point Likert Scale . Read more articles here : https://businessanddigitalmarketing.blogspot.com/2021/07/how-effective-are-google-ads.html

    ReplyDelete
  9. Great Blog...
    it's very knowledgeable information
    it's very effective for learner
    it solution company

    ReplyDelete
  10. If your looking for Online Illinois license plate sticker renewals then you have need to come to the right place.We offer the fastest Illinois license plate sticker renewals in the state. bim consulting

    ReplyDelete
  11. In the wake of looking for a couple of hours on the web, I've had the option to get my R code working and plot bosom malignant growth information on a world guide. It may not the most attractive guide conceivable (R illustrations is amazing!), however I am content with that until further notice.

    ReplyDelete
  12. Thanks for sharing this blog. Very useful Post. Hire Shopify developer to transform your online store and attract new customers.

    Hire Shopify web Developer

    ReplyDelete
  13. This is helpful, nonetheless it can be crucial so that you can check out the following website: Help With Data Analysis For Dissertation

    ReplyDelete
  14. I use basically superior fabrics : you will discover these products by: data analysis help

    ReplyDelete
  15. Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. spss data analysis help

    ReplyDelete
  16. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.
    best data science course

    ReplyDelete
  17. Priority Men's Medical Center is an erectile dysfunction (ED) clinic who's mission is to provide our patients with quick, effective, and affordable ED solutions that work. Schedule a consultation today at our Atlanta, GA location.erectile dysfunction (ED) clinic

    ReplyDelete
  18. This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. Help With Data Analysis For Dissertation

    ReplyDelete
  19. I think this is an informative post and it is very useful and knowledgeable. Hire Dedicated Shopify developer to transform your online store and attract new customers. Dedicated Shopify team.

    hire dedicated shopify developer
    hire shopify web developer

    ReplyDelete
  20. This is a wonderful post, I am very happy to read this article. Thanks for giving us this useful information. Sumit DigiTech is a Best SEO Company in Mansarovar Jaipur, which provides SEO, SMO, Google Ads Management, Web Design, and Development services.

    SEO Company in Jaipur
    SEO Company Jaipur

    ReplyDelete
  21. Thanks for the blog post buddy! Keep them coming... https://nbastreaminglinks.website/

    ReplyDelete
  22. I am definitely enjoying your website. You definitely have some great insight and great stories. https://ufcstreaminglinks.website/

    ReplyDelete
  23. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. https://redditmmastreaming.live/

    ReplyDelete
  24. The website is looking bit flashy and it catches the visitors eyes. Design is pretty simple and a good user friendly interface. https://redditmlbstreaming.live/

    ReplyDelete
  25. Thanks for sharing the post.. parents are worlds best person in each lives of individual..they need or must succeed to sustain needs of the family. https://mlbstreaminglinks.website/

    ReplyDelete
  26. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. https://redditnflstreamings.live/

    ReplyDelete
  27. hi was just seeing if you minded a comment. i like your website and the thme you picked is super. I will be back. https://redditnbastreaming.live/

    ReplyDelete
  28. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. https://redditnhlstreaming.live/

    ReplyDelete
  29. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. https://redditufcstream.live/

    ReplyDelete
  30. You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. Minecraft servers

    ReplyDelete
  31. The thinking process of this going to change with all the nice and great activities.
    Mumbai High Profile Girls
    Independent Girls Service in Delhi

    ReplyDelete
  32. Great info! I recently came across your blog and have been reading along Bioocean Fantasy. I thought I would leave my first comment. I don’t know what to say except that I have.

    ReplyDelete