A simple look into tidygapminder

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 possesion of two super powers (functions): tidy_indice and tidy_bunch.

tidy_indice

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)

df
#>               V1     V2     V3     V4     V5     V6     V7     V8     V9    V10
#>   1:     country 1800.0 1801.0 1802.0 1803.0 1804.0 1805.0 1806.0 1807.0 1808.0
#>   2: Afghanistan   28.2   28.2   28.2   28.2   28.2   28.2   28.1   28.1   28.1
#>   3:     Albania   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:     Algeria   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     Andorra     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                           
#> 184:   Venezuela   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:     Vietnam   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:       Yemen   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:      Zambia   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:    Zimbabwe   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V11    V12    V13    V14    V15    V16    V17    V18    V19    V20
#>   1: 1809.0 1810.0 1811.0 1812.0 1813.0 1814.0 1815.0 1816.0 1817.0 1818.0
#>   2:   28.1   28.1   28.1   28.1   28.1   28.1   28.1   28.1   28.0   28.0
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V21    V22    V23    V24    V25    V26    V27    V28    V29    V30
#>   1: 1819.0 1820.0 1821.0 1822.0 1823.0 1824.0 1825.0 1826.0 1827.0 1828.0
#>   2:   28.0   28.0   28.0   28.0   28.0   28.0   27.9   27.9   27.9   27.9
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V31    V32    V33    V34    V35    V36    V37    V38    V39    V40
#>   1: 1829.0 1830.0 1831.0 1832.0 1833.0 1834.0 1835.0 1836.0 1837.0 1838.0
#>   2:   27.9   27.9   27.9   27.9   27.9   27.9   27.9   27.8   27.8   27.8
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V41    V42    V43    V44    V45    V46    V47    V48    V49    V50
#>   1: 1839.0 1840.0 1841.0 1842.0 1843.0 1844.0 1845.0 1846.0 1847.0 1848.0
#>   2:   27.8   27.8   27.8   27.8   27.8   27.8   27.8   27.7   27.7   27.7
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V51    V52    V53    V54    V55    V56    V57    V58    V59    V60
#>   1: 1849.0 1850.0 1851.0 1852.0 1853.0 1854.0 1855.0 1856.0 1857.0 1858.0
#>   2:   27.7   27.7   27.7   27.7   27.7   27.7   27.6   27.6   27.6   27.6
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   20.0   15.0   22.0   28.8   28.8   28.8   28.8   28.8   28.8   28.8
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V61    V62    V63    V64    V65    V66    V67    V68    V69    V70
#>   1: 1859.0 1860.0 1861.0 1862.0 1863.0 1864.0 1865.0 1866.0 1867.0 1868.0
#>   2:   27.6   27.6   27.6   27.6   27.6   27.6   27.5   27.5   27.5   27.5
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   28.8   28.8   28.8   28.8   28.8   28.8   28.8   28.8   21.0   11.0
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2   32.2
#> 185:   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0   32.0
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6
#> 188:   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7   33.7
#>         V71    V72    V73    V74    V75    V76    V77    V78    V79    V80
#>   1: 1869.0 1870.0 1871.0 1872.0 1873.0 1874.0 1875.0 1876.0 1877.0 1878.0
#>   2:   27.5   27.5   27.6   27.6   27.7   27.7   27.8   27.8   27.9   28.0
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   15.0   22.0   28.9   28.9   28.9   29.0   29.0   29.1   29.1   29.1
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.2   32.2   32.2   32.2   32.2   32.2   32.3   32.3   32.3   32.3
#> 185:   32.0   32.0   32.0   31.9   31.9   31.9   31.9   31.8   31.8   31.8
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4   23.4
#> 187:   32.6   32.6   32.6   32.7   32.7   32.8   32.8   32.9   32.9   33.0
#> 188:   33.7   33.7   33.7   33.7   33.8   33.8   33.8   33.8   33.8   33.8
#>         V81    V82    V83    V84    V85    V86    V87    V88    V89    V90
#>   1: 1879.0 1880.0 1881.0 1882.0 1883.0 1884.0 1885.0 1886.0 1887.0 1888.0
#>   2:   28.0   28.1   28.1   28.2   28.2   28.3   28.4   28.4   28.5   28.5
#>   3:   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4   35.4
#>   4:   29.2   29.2   29.3   29.3   29.4   29.4   29.4   29.5   29.5   29.6
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.3   32.3   32.3   32.3   32.3   32.3   32.3   32.4   32.4   32.4
#> 185:   31.7   31.7   31.7   31.6   31.6   31.6   31.5   31.5   31.5   31.4
#> 186:   23.4   23.4   23.4   23.4   23.4   23.4   23.5   23.5   23.5   23.5
#> 187:   33.0   33.0   33.1   33.1   33.2   33.2   33.3   33.3   33.4   33.4
#> 188:   33.9   33.9   33.9   33.9   33.9   33.9   34.0   34.0   34.0   34.0
#>         V91    V92    V93    V94    V95    V96    V97    V98    V99   V100
#>   1: 1889.0 1890.0 1891.0 1892.0 1893.0 1894.0 1895.0 1896.0 1897.0 1898.0
#>   2:   28.6   28.6   28.7   28.8   28.8   28.9   28.9   29.0   29.1   29.1
#>   3:   35.4   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5
#>   4:   29.6   29.6   29.7   29.7   29.8   29.8   29.8   29.9   29.9   30.0
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.4   32.4   32.4   32.4   32.4   32.4   32.4   32.5   32.5   32.5
#> 185:   31.4   31.4   31.4   31.3   31.3   31.3   31.2   31.2   31.2   31.1
#> 186:   23.5   23.5   23.5   23.5   23.5   23.5   23.5   23.5   23.5   23.5
#> 187:   33.4   33.5   33.5   33.6   33.6   33.6   33.7   33.7   33.8   33.8
#> 188:   34.0   34.0   34.0   34.1   34.1   34.1   34.1   34.1   34.1   34.2
#>        V101   V102   V103   V104   V105   V106   V107   V108   V109   V110
#>   1: 1899.0 1900.0 1901.0 1902.0 1903.0 1904.0 1905.0 1906.0 1907.0 1908.0
#>   2:   29.2   29.2   29.3   29.3   29.4   29.4   29.5   29.6   29.6   29.7
#>   3:   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5
#>   4:   30.0   30.1   30.2   30.3   31.3   25.3   28.0   29.5   29.4   29.3
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.5   32.5   32.5   32.5   32.5   32.5   32.5   32.5   32.6   32.6
#> 185:   31.1   31.1   31.0   31.0   31.0   30.9   30.9   30.9   30.9   30.8
#> 186:   23.5   23.5   23.5   23.5   23.5   23.6   23.6   23.6   23.6   23.6
#> 187:   33.9   33.9   34.0   34.0   34.0   34.1   34.1   34.2   34.2   34.3
#> 188:   34.2   34.2   34.2   34.2   34.2   34.3   34.3   34.3   34.3   34.3
#>        V111   V112   V113   V114   V115   V116   V117   V118   V119    V120
#>   1: 1909.0 1910.0 1911.0 1912.0 1913.0 1914.0 1915.0 1916.0 1917.0 1918.00
#>   2:   29.7   29.8   29.8   29.9   29.9   30.0   30.1   30.1   30.2    7.89
#>   3:   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   19.50
#>   4:   30.9   32.5   32.3   33.7   31.5   31.0   30.5   30.1   30.2   23.60
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA      NA
#>  ---                                                                       
#> 184:   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   32.6   29.60
#> 185:   30.8   30.8   30.7   30.7   30.7   30.6   30.6   30.6   30.6   19.60
#> 186:   23.6   23.6   23.6   23.6   23.6   23.6   23.6   23.6   23.6   19.60
#> 187:   34.3   34.4   34.4   34.4   34.5   34.5   34.6   34.6   34.7   13.40
#> 188:   34.3   34.4   34.4   34.4   34.4   34.4   34.4   34.5   34.5   17.40
#>        V121   V122   V123   V124   V125   V126   V127   V128   V129   V130
#>   1: 1919.0 1920.0 1921.0 1922.0 1923.0 1924.0 1925.0 1926.0 1927.0 1928.0
#>   2:   30.3   30.3   30.4   30.4   30.5   30.6   30.6   30.7   30.7   30.8
#>   3:   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5   35.5
#>   4:   30.3   29.4   29.5   29.2   31.8   33.3   34.1   33.4   28.6   32.2
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   32.7   32.7   32.7   32.7   32.7   32.7   32.7   32.7   32.9   33.1
#> 185:   30.5   30.5   30.4   30.4   30.4   30.3   30.3   30.3   30.2   30.2
#> 186:   23.6   23.6   23.6   23.6   23.6   23.6   23.6   23.6   23.6   23.7
#> 187:   34.8   34.8   34.8   34.9   34.9   35.0   35.0   35.1   35.1   35.1
#> 188:   34.5   34.5   34.5   34.6   34.6   34.6   34.6   34.6   34.6   34.6
#>        V131   V132   V133   V134   V135   V136   V137   V138   V139   V140
#>   1: 1929.0 1930.0 1931.0 1932.0 1933.0 1934.0 1935.0 1936.0 1937.0 1938.0
#>   2:   30.8   30.9   30.9   31.0   31.1   31.1   31.2   31.2   31.3   31.3
#>   3:   35.5   36.4   37.3   38.2   39.1   40.0   40.9   41.8   42.8   43.6
#>   4:   32.5   33.8   31.7   33.1   34.3   33.7   35.6   36.8   34.9   34.3
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   33.3   33.5   33.6   33.8   34.0   34.2   34.4   34.6   35.8   37.0
#> 185:   30.2   30.1   30.3   30.4   30.5   30.6   30.8   30.9   32.1   33.4
#> 186:   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.7
#> 187:   35.2   35.2   35.3   35.3   35.4   35.4   35.5   35.5   35.5   35.6
#> 188:   34.7   34.7   34.7   34.7   34.7   34.8   34.8   34.8   34.8   34.8
#>        V141   V142   V143   V144   V145   V146   V147   V148   V149   V150
#>   1: 1939.0 1940.0 1941.0 1942.0 1943.0 1944.0 1945.0 1946.0 1947.0 1948.0
#>   2:   31.4   31.4   31.5   31.6   31.6   31.7   31.7   31.8   31.8   31.9
#>   3:   43.2   42.2   41.7   40.2   37.2   34.2   47.2   50.3   51.8   52.7
#>   4:   36.6   37.1   35.3   34.7   30.0   35.5   33.2   35.4   38.8   42.0
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   38.3   39.5   40.8   42.4   44.0   45.6   47.2   48.9   50.5   52.1
#> 185:   34.6   33.6   32.7   32.1   30.7   25.1   15.8   33.4   38.9   43.5
#> 186:   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.7   23.8
#> 187:   35.6   35.7   35.7   35.8   35.8   35.9   35.9   37.8   39.8   41.8
#> 188:   34.8   34.9   36.3   37.8   39.3   40.7   42.2   43.6   45.1   46.6
#>        V151   V152   V153   V154   V155   V156   V157   V158   V159   V160
#>   1: 1949.0 1950.0 1951.0 1952.0 1953.0 1954.0 1955.0 1956.0 1957.0 1958.0
#>   2:   31.9   32.0   32.4   33.0   33.7   34.4   35.1   35.8   36.5   37.2
#>   3:   53.6   54.5   54.7   55.2   55.8   56.5   57.3   58.3   59.3   60.4
#>   4:   44.4   46.9   47.1   47.6   48.1   48.6   49.2   49.7   50.3   50.9
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   53.7   55.3   55.6   56.3   56.9   57.5   58.0   58.7   59.3   59.9
#> 185:   46.2   47.9   48.2   48.9   49.6   50.3   51.0   51.6   52.2   52.8
#> 186:   23.8   23.8   24.2   25.2   26.2   27.1   28.1   29.1   30.1   31.0
#> 187:   43.7   45.7   46.0   46.5   47.0   47.5   48.0   48.6   49.1   49.6
#> 188:   48.1   49.5   49.8   50.3   50.7   51.2   51.6   52.1   52.5   53.0
#>        V161   V162   V163   V164   V165   V166   V167   V168   V169   V170
#>   1: 1959.0 1960.0 1961.0 1962.0 1963.0 1964.0 1965.0 1966.0 1967.0 1968.0
#>   2:   37.9   38.6   39.4   40.1   40.8   41.5   42.2   42.9   43.7   44.4
#>   3:   61.6   62.7   63.7   64.6   65.3   65.9   66.3   66.5   66.7   66.9
#>   4:   51.4   52.0   52.6   53.2   53.8   54.3   54.9   55.4   56.0   56.5
#>   5:     NA     NA     NA     NA     NA     NA     NA     NA     NA     NA
#>  ---                                                                      
#> 184:   60.5   61.1   61.7   62.4   63.0   63.6   64.2   64.7   65.3   65.9
#> 185:   53.4   53.9   54.5   55.0   55.6   56.0   56.3   56.3   56.0   55.4
#> 186:   32.0   33.0   33.9   34.9   35.8   36.7   37.6   38.5   39.4   40.3
#> 187:   50.1   50.6   51.1   51.5   52.0   52.5   52.9   53.4   53.9   54.5
#> 188:   53.4   53.8   54.3   54.6   55.0   55.4   55.8   56.2   56.5   56.9
#>        V171   V172   V173   V174   V175   V176   V177   V178   V179   V180
#>   1: 1969.0 1970.0 1971.0 1972.0 1973.0 1974.0 1975.0 1976.0 1977.0 1978.0
#>   2:   45.1   45.8   45.9   45.9   46.0   46.1   46.3   46.5   46.6   45.0
#>   3:   67.1   67.4   68.0   68.6   69.2   69.8   70.3   70.8   71.3   71.7
#>   4:   57.0   57.5   57.8   58.2   58.5   59.1   59.5   60.0   60.6   61.2
#>   5:     NA   76.0   76.3   76.6   76.9   77.2   77.4   77.7   78.0   78.3
#>  ---                                                                      
#> 184:   66.4   66.9   66.8   66.9   67.0   67.5   67.9   68.3   69.0   69.4
#> 185:   54.6   53.9   54.5   50.6   54.6   53.6   61.2   63.0   63.4   63.8
#> 186:   41.1   42.0   44.5   45.4   46.6   47.6   48.6   49.7   50.7   51.5
#> 187:   55.1   55.6   56.1   56.5   57.0   57.4   57.6   57.9   58.0   58.1
#> 188:   57.2   57.6   57.9   58.3   58.5   58.8   59.1   58.8   58.4   56.7
#>        V181   V182   V183   V184   V185   V186   V187   V188   V189   V190
#>   1: 1979.0 1980.0 1981.0 1982.0 1983.0 1984.0 1985.0 1986.0 1987.0 1988.0
#>   2:   43.6   43.3   44.1   43.8   42.0   39.8   41.6   42.6   44.7   47.0
#>   3:   72.0   72.3   72.4   72.5   72.6   72.8   73.0   73.2   73.2   73.4
#>   4:   61.9   62.1   63.4   64.4   65.7   66.9   68.0   68.7   69.4   70.0
#>   5:   78.6   78.7   78.8   78.8   78.8   79.0   79.1   79.2   79.3   79.3
#>  ---                                                                      
#> 184:   69.8   70.0   70.4   70.6   71.1   71.5   71.8   72.3   72.2   72.5
#> 185:   63.1   64.5   64.9   65.3   65.7   66.2   66.5   66.9   67.3   67.6
#> 186:   52.4   53.1   53.9   54.1   55.4   56.0   56.6   54.6   57.5   57.9
#> 187:   58.2   57.8   57.7   57.5   57.3   56.9   56.3   55.6   55.0   54.7
#> 188:   57.2   60.4   61.3   61.8   62.2   62.7   63.1   63.5   63.6   63.2
#>        V191   V192   V193   V194   V195   V196   V197   V198   V199   V200
#>   1: 1989.0 1990.0 1991.0 1992.0 1993.0 1994.0 1995.0 1996.0 1997.0 1998.0
#>   2:   50.8   51.6   51.3   51.4   51.4   50.7   51.1   51.4   51.1   50.1
#>   3:   73.7   73.9   73.9   73.9   73.9   74.0   74.1   74.3   72.5   74.3
#>   4:   70.5   71.0   71.4   71.7   72.0   72.1   72.3   72.8   73.0   73.1
#>   5:   79.4   79.5   79.5   79.6   79.8   80.0   80.3   80.6   81.0   81.3
#>  ---                                                                      
#> 184:   72.5   72.7   72.6   72.6   72.7   72.7   73.0   73.5   74.0   74.1
#> 185:   67.9   68.2   68.4   68.7   69.0   69.2   69.5   69.8   69.9   70.3
#> 186:   58.3   58.7   59.1   59.5   59.8   59.9   60.5   60.8   61.3   61.7
#> 187:   53.5   52.3   50.8   49.5   48.6   47.5   46.5   45.7   45.1   44.6
#> 188:   62.7   61.7   61.0   59.4   57.6   55.8   53.7   52.2   50.8   49.1
#>        V201   V202   V203   V204   V205   V206   V207   V208   V209   V210
#>   1: 1999.0 2000.0 2001.0 2002.0 2003.0 2004.0 2005.0 2006.0 2007.0 2008.0
#>   2:   51.5   51.6   51.7   52.4   53.0   53.5   53.9   54.1   54.6   55.2
#>   3:   74.4   74.4   74.5   74.5   74.6   74.7   74.9   75.2   75.4   75.6
#>   4:   73.5   73.9   74.1   74.4   74.5   75.1   75.4   75.6   75.9   76.1
#>   5:   81.5   81.8   82.0   82.3   82.4   82.3   82.5   82.5   82.7   82.7
#>  ---                                                                      
#> 184:   70.7   74.3   74.4   74.3   74.2   74.9   75.1   75.0   75.0   74.9
#> 185:   70.5   70.7   70.9   71.1   71.3   71.5   71.8   72.0   72.3   72.5
#> 186:   62.1   62.6   63.1   63.5   64.0   64.5   65.0   65.5   65.8   66.4
#> 187:   44.3   44.1   43.9   44.4   44.6   45.3   46.0   46.7   47.8   49.4
#> 188:   47.8   46.7   46.2   45.6   45.3   45.1   45.3   45.7   46.4   46.7
#>        V211   V212   V213   V214   V215   V216   V217   V218   V219   V220
#>   1: 2009.0 2010.0 2011.0 2012.0 2013.0 2014.0 2015.0 2016.0 2017.0 2018.0
#>   2:   55.7   56.2   56.7   57.2   57.7   57.8   57.9   58.0   58.4   58.7
#>   3:   75.9   76.3   76.7   77.0   77.2   77.4   77.6   77.7   77.9   78.0
#>   4:   76.3   76.5   76.7   76.8   77.0   77.1   77.3   77.4   77.6   77.9
#>   5:   82.7   82.7   82.6   82.6   82.6   82.6   82.5   82.5     NA     NA
#>  ---                                                                      
#> 184:   75.0   75.4   75.4   75.3   75.4   75.5   75.5   75.5   75.7   75.9
#> 185:   72.8   73.1   73.3   73.6   73.8   74.1   74.3   74.5   74.7   74.9
#> 186:   67.0   67.5   67.7   67.9   68.4   68.4   67.2   66.7   66.9   67.1
#> 187:   50.7   52.0   53.2   54.5   55.7   57.0   58.1   58.8   59.1   59.5
#> 188:   47.5   49.6   51.9   54.1   55.6   57.0   58.3   59.3   59.8   60.2

# To................................

tidy_indice(filepath)
#> # A tibble: 40,953 x 3
#>    country      year life_expectancy_years
#>    <chr>       <dbl>                 <dbl>
#>  1 Afghanistan  1800                  28.2
#>  2 Afghanistan  1801                  28.2
#>  3 Afghanistan  1802                  28.2
#>  4 Afghanistan  1803                  28.2
#>  5 Afghanistan  1804                  28.2
#>  6 Afghanistan  1805                  28.2
#>  7 Afghanistan  1806                  28.1
#>  8 Afghanistan  1807                  28.1
#>  9 Afghanistan  1808                  28.1
#> 10 Afghanistan  1809                  28.1
#> # … with 40,943 more rows

tidy_bunch

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", "gapminder", package = "tidygapminder")

# From ................................
list.files(dir_path)
#> [1] "aid_received_per_person_current_us.csv"                    
#> [2] "income_per_person_gdppercapita_ppp_inflation_adjusted.xlsx"

# To ..................................
tidy_bunch(dir_path, merge = TRUE)
#> We take in only csv or xlsx files
#> # A tibble: 55,462 x 4
#>    country     year aid_received_per_person_… income_per_person_gdppercapita_pp…
#>    <chr>      <dbl>                     <dbl>                              <dbl>
#>  1 Afghanist…  1960                      1.91                                 NA
#>  2 Afghanist…  1961                      3.78                                 NA
#>  3 Afghanist…  1962                      1.81                                 NA
#>  4 Afghanist…  1963                      3.85                                 NA
#>  5 Afghanist…  1964                      4.74                                 NA
#>  6 Afghanist…  1965                      5.43                                 NA
#>  7 Afghanist…  1966                      4.96                                 NA
#>  8 Afghanist…  1967                      3.91                                 NA
#>  9 Afghanist…  1968                      2.76                                 NA
#> 10 Afghanist…  1969                      2.51                                 NA
#> # … with 55,452 more rows

Enjoy!!!