-
Notifications
You must be signed in to change notification settings - Fork 10
/
RNotebookExample1.Rmd
38 lines (30 loc) · 1.61 KB
/
RNotebookExample1.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
---
title: "RNotebookExample"
author: "Alexia Cardona"
output: html_document
date: "`r format(Sys.time(), '%d %B %Y')`"
---
This report contains the analysis of the `gapminder` dataset and contains the results of the top Countries with the largest life expectancy in Europe. The analysis is based on data from 2007. The report also analyzes how life expectancy changed over the years in Europe.
This report was generated using R and the code to extract the European 2007 data is as follows:
```{r load-data, message=FALSE}
#load tidyverse library
library(tidyverse) # used for data manipulation
library(rmarkdown) # used for paged_table function
library(kableExtra) # used for table
library(ggpubr) #used for ggarrange function
#read file into R
pop_data <- read_csv("data/gapminder_data.csv")
#create a table with data from European countries in 2007 showing the countries with the largest life expectancy at the top
euro_data_tbl <- pop_data %>%
filter(continent == "Europe" & year == 2007) %>%
select(-continent, -year) %>%
arrange(desc(lifeExp)) %>%
rename(Country = country, "Population Size" = pop, "Life Expectancy" = lifeExp, "GDP" = gdpPercap)
```
The results in euro_data_tbl are displayed in the Table below:
```{r kbl-table}
euro_data_tbl %>%
kable(caption="European countries ordered by greatest life expectancy from 2007 data") %>%
kable_styling(bootstrap_options = "striped", full_width = F) %>%
scroll_box(width = "100%", height = "200px")
```