-
Notifications
You must be signed in to change notification settings - Fork 0
/
shinde_1.Rmd
89 lines (55 loc) · 2.81 KB
/
shinde_1.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: "datalab-ch2_vis04"
author: "Ajinkya Shinde"
date: "14th May 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r echo=FALSE,warning=FALSE,message=FALSE,error=FALSE}
library(gapminder)
library(dplyr)
library(ggplot2)
library(skimr)
```
### 1. Relevant R-code
```{r warning=FALSE,error=FALSE}
meanGDP_country <- gapminder %>%
group_by(country,continent) %>%
summarize(meanGdp=mean(gdpPercap))
ggplot(meanGDP_country,aes(x=meanGdp)) + geom_histogram(binwidth=500,fill="white",color="black") +
coord_cartesian(xlim=c(0,30000))+
facet_wrap(~continent)+
xlab("Mean GDP across countries within continent")
```
### 2. Description of the Type of Graph
This is a histogram used to measure the spread of GDP across countries within each continent
### 3. Description of the DATA used
```{r}
glimpse(meanGDP_country)
```
The Data consists of nominal/qualitative variables - country and continent and the quantitative variable is meanGDP which is calculated as the mean of GDP across a country in a given continent
### 4. Description of the AUDIENCE
This dataset can be used for census analyst who wants to
see the GDP growth across the continents from the data set
### 5. Representation description
In the above graph, we are trying to see the spread of gdp across countries within each continent. The facet_wrap
divides the graph across Continent. In each of the individual graph,individual bar line represents mean of GDP across the countries. The visualization can be used to get the sense of skewness/type of distribution across the continent.
### 6. How to read it & what to look for?
We try to see the skewness and get a general idea of distribution of GDP across each of the continent. A newbie can say that the graph for Europe looks normally distributed and should look to get basic sense of distribution.
### 7. Presentation Tips:
We can use discrete color palette to differentiate among the different ordinal variables. Also , the distinct color scheme also portrays that the distribution for each continent is independent of each other.
### 8. Variations and creations:
Below is the variation of the above graph. A ridge line
chart below can be used to compare the distributions amongst themselves to see which how the continents perform against each other.
```{r warning=FALSE,error=FALSE}
library(ggridges)
ggplot(meanGDP_country,aes(x=meanGdp,y=continent,color=continent)) +
geom_density_ridges(scale = 0.9)+
scale_color_hue(l = 45)+
xlab("Mean GDP across countries within continent")+
ylab("Continent")
```
### 9. How I created it?
I thought of showing countries in a single graph with graph being created for each continent. Thus, I created meanGDP_country variable to store the dataset in that format.Finally, used GGPlot2 to create the histogram.