examples.Rmd
First, load the library:
library(twstats)
First, find tables you are interested in. Generally you do this by specifying the columns:
twstats_find_tables('year/country/value')
## character(0)
…you can also use wildcards if you don’t care what sort of column it is:
head(twstats_find_tables('*/value'))
## [1] "eurostat/tps00070/country:DE" "eurostat/tps00070/country:CY"
## [3] "eurostat/tps00070/country:CZ" "eurostat/tps00070/country:DK"
## [5] "eurostat/tps00070/country:EE" "eurostat/tps00070/country:EL"
Given a table name, you can get more detail:
twstats_get_table('eurostat/tin00073/country:IS')[c('name', 'title', 'source')]
## $name
## [1] "eurostat/tin00073/country:IS"
##
## $title
## [1] "Households with broadband access, Percentage of households, Iceland"
##
## $source
## [1] "<a href=\"http://appsso.eurostat.ec.europa.eu/nui/show.do?dataset=tin00073&lang=en\">Eurostat</a>"
Finally, we can get the data itself by calling it’s data function:
twstats_get_table('eurostat/tin00073/country:IS')$data()
## # A tibble: 10 x 2
## year `Percentage of households`
## <dbl> <dbl>
## 1 2007 76
## 2 2008 83
## 3 2009 87
## 4 2010 87
## 5 2011 92
## 6 2012 93
## 7 2013 95
## 8 2014 93
## 9 2017 96
## 10 2018 97
The value column specifies any continuous numeric value. It’s actual name in the data tells you what the values represent. In addition to the above, there are tables with multiple value columns, for comparison questions. For example:
twstats_get_table('eurostat/tin00073/country:DE/country:FR')$title
## [1] "Households with broadband access, Percentage of households, Germany (until 1990 former territory of the FRG)-France"
twstats_get_table('eurostat/tin00073/country:DE/country:FR')$data()
## year Percentage of households - DE Percentage of households - FR
## 1 2007 50 49
## 2 2008 55 57
## 3 2009 65 63
## 4 2010 75 66
## 5 2011 78 70
## 6 2012 82 77
## 7 2013 85 78
## 8 2014 87 77
## 9 2015 88 76
## 10 2016 90 79
## 11 2017 92 79
## 12 2018 90 81