Skip to content

Commit

Permalink
update commit
Browse files Browse the repository at this point in the history
  • Loading branch information
iamericfletcher committed Nov 12, 2020
1 parent f1f4618 commit c7ae121
Show file tree
Hide file tree
Showing 14 changed files with 167 additions and 3 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified 2020/.DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion 2020/Data/test.txt

This file was deleted.

Binary file added 2020/Images/.DS_Store
Binary file not shown.
Binary file modified 2020/Plots/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions 2020/Plots/2020_44/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Rplot.png
Rplot01.png
Rplot02.png
Rplot03.png
Rplot04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions 2020/R/2020_44_Canadian_Wind_Turbines.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ According to their website:
### Data and library Import

```{r}
options(scipen = 999)
library(tidytuesdayR)
library(tidyverse)
library(rnaturalearth)
Expand Down Expand Up @@ -124,8 +125,6 @@ ggplot() +
```

```{r}
options(scipen = 999)
# Determine if projects cover multiple years.
wind_turbine %>%
distinct(project_name, commissioning_date) %>%
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 156 additions & 0 deletions 2020/R/2020_46_Historical_Phones.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
title: "2020_46_Historical_Phones"
author: "Eric Fletcher"
date: "11/10/2020"
output: html_document
---

The data is provided by [Our World in Date](https://ourworldindata.org/technology-adoption#technology-leapfrogging), and was accessed via the [TidyTuesday](https://github.com/rfordatascience/tidytuesday) community of practice.

```{r Package Import}
library(tidytuesdayR)
library(tidyverse)
```

```{r Data Import}
# Using the tidytuesdayR package which loads the datasets as well as the readme.
tuesdata <- tidytuesdayR::tt_load('2020-11-10')
# Readme.
tuesdata
# Rename the datasets.
mobile_raw <- tuesdata$mobile
landline_raw <- tuesdata$landline
# View the datasets.
mobile_raw
landline_raw
```

```{r Data Cleaning}
# Combine the two data sets.
mobile_raw
landline_raw
mobile_clean <- mobile_raw %>%
rename(subs = mobile_subs) %>%
mutate(
type = "Mobile"
)
landline_clean <- landline_raw %>%
rename(subs = landline_subs) %>%
mutate(
type = "Landline"
)
phone_combined <-bind_rows(mobile_clean, landline_clean)
```

### Observations:

- There are 5 continents:

- Africa
- Asia
- Europe
- Americas
- Oceania

- There are 238 countries.

- The data spans from 1990 to 2017.

```{r Data Overview}
### Data Summary:
# NA summary.
colMeans(is.na(mobile_raw))
colMeans(!is.na(landline_raw))
# Data summary.
skimr::skim(mobile_raw)
skimr::skim(landline_raw)
### Basic Counts:
mobile_raw %>%
count(continent, sort = TRUE)
landline_raw %>%
count(continent, sort = TRUE)
# Count the number of years.
# Mobile - 1990 to 2017.
mobile_raw %>%
count(year)
# Landline - 1990 to 2019.
landline_raw %>%
count(year)
```

### Exploratory Data Analysis

```{r EDA 1}
# Let's look at the United States.
phone_combined %>%
filter(entity == "United States") %>%
ggplot(aes(x = year, y = subs)) +
geom_line(aes(color = type)) +
labs(
title = "Landline versus Mobile Subscriptions in the United States",
subtitle = "1990 to 2019",
caption = "Data Source: Our Word in Data | Plot: Eric Fletcher",
color = "Type",
x = "Year",
y = "Subscriptions (per 100 people)"
) +
theme_set(theme_light())
```

```{r - EDA 2}
# Let's take a look at every entity (Country) included in the data set.
phone_combined %>%
ggplot(aes(x = year, y = subs, color = type, group = interaction(type, entity))) +
geom_line() +
labs(
title = "Landline versus Mobile Subscriptions",
subtitle = "Every Country, 1990 to 2019",
caption = "Data Source: Our Word in Data | Plot: Eric Fletcher",
color = "Type",
x = "Year",
y = "Subscriptions (per 100 people)"
)
```

```{r EDA 3}
# Let's take the previous plot and show only the most populated countries.
top_population <- phone_combined %>%
group_by(entity) %>%
summarise(
average_pop = mean(total_pop, na.rm = TRUE)
) %>%
arrange(desc(average_pop))
phone_combined %>%
semi_join(top_population %>% top_n(20, wt = average_pop)) %>%
ggplot(aes(x = year, y = subs, color = type, group = interaction(type, entity))) +
geom_line() +
geom_hline(yintercept = 50, lty = 2) +
labs(
title = "Landline versus Mobile Subscriptions",
subtitle = "Top Countries by Average Population, 1990 to 2019",
caption = "Data Source: Our Word in Data | Plot: Eric Fletcher",
color = "Type",
x = "Year",
y = "Subscriptions (per 100 people)"
) +
facet_wrap(~continent)
```
Binary file added 2020/data/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions 2020/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
92-160-g2011001-eng.pdf
gpr_000b11a_e.dbf
gpr_000b11a_e.prj
gpr_000b11a_e.shp
gpr_000b11a_e.shx

0 comments on commit c7ae121

Please sign in to comment.