DS Labs Assignment
Loading the dslabs data plots and installing necessary packages.
library("dslabs")
data(package="dslabs")
list.files(system.file("script", package = "dslabs"))
## [1] "make-admissions.R"
## [2] "make-brca.R"
## [3] "make-brexit_polls.R"
## [4] "make-death_prob.R"
## [5] "make-divorce_margarine.R"
## [6] "make-gapminder-rdas.R"
## [7] "make-greenhouse_gases.R"
## [8] "make-historic_co2.R"
## [9] "make-mnist_27.R"
## [10] "make-movielens.R"
## [11] "make-murders-rda.R"
## [12] "make-na_example-rda.R"
## [13] "make-nyc_regents_scores.R"
## [14] "make-olive.R"
## [15] "make-outlier_example.R"
## [16] "make-polls_2008.R"
## [17] "make-polls_us_election_2016.R"
## [18] "make-reported_heights-rda.R"
## [19] "make-research_funding_rates.R"
## [20] "make-stars.R"
## [21] "make-temp_carbon.R"
## [22] "make-tissue-gene-expression.R"
## [23] "make-trump_tweets.R"
## [24] "make-weekly_us_contagious_diseases.R"
## [25] "save-gapminder-example-csv.R"
#install.packages("RColorBrewer")
Loading packages and greenhouse_gases plot.
data("greenhouse_gases")
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.3 v purrr 0.3.4
## v tibble 3.1.2 v dplyr 1.0.6
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 1.4.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(dslabs)
library(RColorBrewer)
view(greenhouse_gases)
Renaming the dataset.
Creating a line graph, taking sample of the past 500 years (1500 to 2000 AD).
Adding title, x/y axis, then drawing the chart.
gas_pollution <- greenhouse_gases %>%
ggplot(aes(x = year, y = concentration)) +
xlim(1500,2000) +
labs(title = "Greenhouse Gas Emissions for the past 500 years") +
xlab("Year") +
ylab("Gas Concentration") +
theme_light(base_size = 15)
gas_pollution +
geom_line(aes(color = gas)) +
geom_point() +
labs(color = "Gas") +
scale_color_brewer(palette = "Dark2")
## Warning: Removed 222 row(s) containing missing values (geom_path).
## Warning: Removed 222 rows containing missing values (geom_point).
