Description Datakindr statbank functions Datakindr Plotting Examples
Provides tools, utilities, data and more for use by the DataKind Dublin team. Including a convenient interface to CSO.ie's Statbank and a ggplot2 theme and colour palette for convenient & consistent visualisation styles.
For interacting with CSO.ie datasets, the following two functions can be used:
search_statbank_datasets()
returns a data frame with dataset
codes and a description of the dataset to which each code refers.
Once you've found the dataset you need (either from the Statbank website,
or by using search_statbank_datasets()
) you can use
get_cso_dataset()
to retrieve the dataset as a data.frame.
A number of convenience objects have been provided as part of this package to make creating consistent visualisations when using ggplot2.
dk_theme
ggplot2 theme object that can be used as a starting point when creating visualisations for Datakind to create a consistent look and feel.
dk_palette
Main 4-colour palette. Comes bundled with
dk_theme
.
dk_sequential_palette
Extended 7-colour palette for use with sequential data series.
dk_non_sequential_palette
Extended 5-colour palette for use with non-sequential data series.
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 | # Querying CSO.ie Statbank
## Not run:
dataset_names <- search_statbank_datasets("garda")
garda_dataset <- get_cso_dataset(dataset_names$dataset_code[1])
View(garda_dataset)
## End(Not run)
## Not run:
# Use of ggplot2 theme and datakind palette:
ggplot2::ggplot(data.frame( y = runif(100, min = 0, max = 20) +
seq(1, 100, 1),
x = seq(1, 100, 1),
z = rep_len(c("a", "b", "c", "d"), 100)),
ggplot2::aes(x, y, colour = z, fill = z)) +
ggplot2::geom_point() +
ggplot2::facet_wrap(~z, nrow = 2) +
ggplot2::geom_smooth(se = TRUE) +
ggplot2::labs(title = "Some Data (2011)",
x = "Range", y = "Value") +
dk_theme
ggplot2::ggplot(data.frame( x = c('Primary 1', 'Primary 2',
'Secondary 1', 'Secondary 2',
"even", "more", "colours"),
y = runif(7, 10, 100)),
ggplot2::aes(x,y, fill = x)) +
ggplot2::geom_bar(stat = "identity") +
ggplot2::labs(title = "Some Data (2011)",
x = "Range", y = "Value") +
dk_theme +
ggplot2::scale_fill_manual(values = dk_sequential_palette)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.