knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This package aims to make really easy to tidy data retrieved from Gapminder. A the beginning is:
library(tidygapminder)
When you have loaded the package you are now in possession of two super powers (functions): tidy_indice and tidy_bunch.
tidy_indice
function tidy as explain above tidy a data sheet downloaded on Gapminder. This data sheet can be either in csv or xlsx as indicated on the gapminder site.
tidy_indice
take as argument the path to the file and return the data as a tidy data frame.
filepath <- system.file("extdata", "life_expectancy_years.csv", package = "tidygapminder") # From ............................. df <- data.table::fread(filepath) head(df) # To................................ ti_df <- tidy_indice(filepath) head(ti_df)
tidy_bunch
makes use of tidy_indice
to tidy a whole set of data sheets and have the options to merge all data frames into one big data frame with merge
set to TRUE
:
dir_path <- system.file("extdata", package = "tidygapminder") # From ................................ list.files(dir_path) # To .................................. td_dp <- tidy_bunch(dir_path, merge = TRUE) head(td_dp)
Enjoy!!!
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.