Question 4

Required libraries.

#install.packages("gapminder")
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.1.1     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(gapminder)
data(gapminder)

Question 6

Gapminder dataset contains information about countries and their life expectancy. It has 1704 rows and 6 variables.

Question 7

Print columns of gapminder as html tables. - As a normal table

gapminder %>%
  colnames() %>%
  data.frame()
##           .
## 1   country
## 2 continent
## 3      year
## 4   lifeExp
## 5       pop
## 6 gdpPercap
gapminder %>%
  colnames() %>%
  knitr::kable(caption = "Gapminder Variable Names",
               col.names = "Colnames")
Gapminder Variable Names
Colnames
country
continent
year
lifeExp
pop
gdpPercap

Question 8

Create a plot of the population vs time of France

# line plot of France population
gapminder %>%
  filter(country=="France") %>%
  ggplot(aes(x = year, y = pop)) +
  ggtitle(label = "Time plot for France population") +
  geom_line() +
  theme(plot.title = element_text(size = 20, face = "bold"))

sessionInfo()
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19042)
## 
## Matrix products: default
## 
## locale:
## [1] LC_COLLATE=English_United States.1252 
## [2] LC_CTYPE=English_United States.1252   
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.1252    
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] gapminder_0.3.0 forcats_0.5.1   stringr_1.4.0   dplyr_1.0.7    
##  [5] purrr_0.3.4     readr_2.1.1     tidyr_1.1.4     tibble_3.1.6   
##  [9] ggplot2_3.3.5   tidyverse_1.3.1
## 
## loaded via a namespace (and not attached):
##  [1] tidyselect_1.1.1 xfun_0.29        bslib_0.3.1      haven_2.4.3     
##  [5] colorspace_2.0-2 vctrs_0.3.8      generics_0.1.1   htmltools_0.5.2 
##  [9] yaml_2.2.1       utf8_1.2.2       rlang_0.4.12     jquerylib_0.1.4 
## [13] pillar_1.6.4     withr_2.4.3      glue_1.6.0       DBI_1.1.2       
## [17] dbplyr_2.1.1     modelr_0.1.8     readxl_1.3.1     lifecycle_1.0.1 
## [21] munsell_0.5.0    gtable_0.3.0     cellranger_1.1.0 rvest_1.0.2     
## [25] evaluate_0.14    labeling_0.4.2   knitr_1.37       tzdb_0.2.0      
## [29] fastmap_1.1.0    fansi_0.5.0      highr_0.9        broom_0.7.11    
## [33] Rcpp_1.0.7       backports_1.4.1  scales_1.1.1     jsonlite_1.7.2  
## [37] farver_2.1.0     fs_1.5.2         hms_1.1.1        digest_0.6.29   
## [41] stringi_1.7.6    grid_4.1.2       cli_3.1.0        tools_4.1.2     
## [45] magrittr_2.0.1   sass_0.4.0       crayon_1.4.2     pkgconfig_2.0.3 
## [49] ellipsis_0.3.2   xml2_1.3.3       reprex_2.0.1     lubridate_1.8.0 
## [53] rstudioapi_0.13  assertthat_0.2.1 rmarkdown_2.11   httr_1.4.2      
## [57] R6_2.5.1         compiler_4.1.2