-
Notifications
You must be signed in to change notification settings - Fork 8
/
README.Rmd
121 lines (88 loc) · 7.01 KB
/
README.Rmd
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# canlang <a href='https://ttimbers.github.io/canlang'><img src='man/figures/hex-canlang.png' align="right" height="138.5" /></a>
<!-- badges: start -->
[![R build status](https://github.com/ttimbers/canlang/workflows/R-CMD-check/badge.svg)](https://github.com/ttimbers/canlang/actions)
[![R build status](https://github.com/ttimbers/canlang/workflows/pkgdown/badge.svg)](https://github.com/ttimbers/canlang/actions)
<!-- badges: end -->
The goal of {canlang} is to easily share language data collected in the 2016 Canadian census. This data was retreived from the 2016 Canadian census data set using the {[cancensus](https://mountainmath.github.io/cancensus/index.html)} R package.
This package contains three data sets:
1. [`can_lang`](#example-usage-of-can_lang): Contains the counts of the total number of Canadians that report each language as their mother tongue, which language they speak most often at home, which language they use most often at work, and which language they have knowledge for.
2. [`region_lang`](#example-usage-of-region_lang): For each census division, it contains the counts of how many Canadians report each language as their mother tongue, which language they speak most often at home, which language they use most often at work, and which language they have knowledge for.
3. [`region_data`](#example-usage-of-region_data): For each census division, it contains the statistics for number of households, land area, population and number of dwellings.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("ttimbers/canlang")
```
## Example usage of `can_lang`
The data set `can_lang` contains the counts of the total number of Canadians that report each language as their mother tongue, which language they speak most often at home, which language they use most often at work, and which language they have knowledge for. This data was recorded in the 2016 Census:
```{r example-can_lang}
library(canlang)
head(can_lang)
```
```{r example-plot-from-data, warning = FALSE, fig.height = 3.5, fig.retina = 2}
library(ggplot2)
ggplot2::ggplot(data = can_lang,
aes(x = most_at_home, y = mother_tongue,
colour = category, shape = category)) +
geom_point(alpha = 0.7) +
scale_color_manual(values = c("blue3","red3","black")) +
scale_y_log10(name = "Number of Canadians reporting the \n language as their mother tongue",
labels = scales::comma) +
scale_x_log10(name = "Number of Canadians speaking the language \n as their primary language at home",
labels = scales::comma) +
annotation_logticks() +
theme_bw()
```
## Example usage of `region_lang`
For each census metropolitan area (CMA), the data set `region_lang` contains the counts of how many Canadians report each language as their mother tongue, which language they speak most often at home, which language they use most often at work, and which language they have knowledge for.
```{r example-region_lang, warning = FALSE, message = FALSE}
library(canlang)
library(dplyr)
region_lang %>%
filter(region == "Vancouver") %>%
arrange(desc(mother_tongue)) %>%
head()
```
## Example usage of `region_data`
For each census metropolitan area (CMA), the data set `region_data` contains the statistics for number of households, land area, population and number of dwellings.
```{r example-region_data, warning = FALSE, message = FALSE}
library(canlang)
library(dplyr)
region_data %>%
arrange(desc(population)) %>%
head()
```
## Plain text, excel and SQLite database files
We have included several different plain text files, an excel files and a SQLite database file in this repo to be used for practice importing from these filetypes. Specifically, they are:
### Canada-level
+ [`can_lang.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/can_lang.csv): the same dataset available via `canlang::can_lang` stored as a vanilla `.csv` file.
+ [`can_lang-meta-data.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/can_lang-meta-data.csv): the same dataset available via `canlang::can_lang` stored as a vanilla `.csv` file with two rows of metadata that should be skipped.
+ [`can_lang.tsv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/can_lang.tsv): the same dataset available via `canlang::can_lang` stored as a `.tsv` (tab separated) file and has no column names.
+ [`can_lang.xlsx`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/can_lang.xlsx): the same dataset available via `canlang::can_lang` stored as a `.xlsx` file. Can be read in using the {[readxl](https://readxl.tidyverse.org/)} package.
+ [`can_lang.db`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/can_lang.db): the same dataset available via `canlang::can_lang` stored as a SQLite database (`.db`) file. Can be read in using the {[RSQLite](https://rsqlite.r-dbi.org/)} package.
### Census metroolitan area (CMA)-level
+ [`vancouver_lang.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/vancouver_lang.csv) & [`calgary_lang.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/calgary_lang.csv): data for Vancouver, BC and Calgary, AB, respectively, stored as a vanilla `.csv` file.
+ [`victoria_lang.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/victoria_lang.csv): data for Victoria, BC stored as a vanilla `.tsv` file.
+ [`kelowna_lang.csv`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/kelowna_lang.csv): data for Kelowna, BC stored as a `.csv` file (csv2 flavour) with metadata in the header and footer that should be skipped.
+ [`abbotsford_lang.xlsx`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/abbotsford_lang.xlsx): data for Abbotsford, BC stored as a `.xlsx` file where sheet 1 is the column names, and sheet 2 is the data with no column names. Can be read in using the {[readxl](https://readxl.tidyverse.org/)} package.
+ [`edmonton_lang.xlsx`](https://github.com/ttimbers/canlang/blob/master/inst/extdata/edmonton_lang.xlsx): data for Edmonton, AB stored as a `.xlsx` file where all the data is in sheet 1.
## How this was made
The [`data-raw`](https://github.com/ttimbers/canlang/tree/master/data-raw) directory contains the the scripts necessary to create everything in this package, including the R data objects and the plain text, excel and SQLite database files.
## References
**Data originally published in:**
+ Source: Statistics Canada, Census of Population, 2016. Reproduced and distributed on an "as is" basis with the permission of Statistics Canada.
**Package development resources:**
+ von Bergmann, J., Aaron Jacobs, Dmitry Shkolnik (2020). cancensus: R package to access, retrieve, and work with Canadian Census data and geography. v0.3.2.