Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mpjashby/crimemappingdata


https://github.com/mpjashby/crimemappingdata

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# crimemappingdata

The crimemappingdata package contains a variety of datasets that are useful in learning crime mapping. These datasets are used in the [crimemapping package](https://github.com/mpjashby/crimemapping/) but are also available for use by anyone else in accordance with the licence shown in the documentation for each dataset.

## Installation

You can install the development version of crimemappingdata from [GitHub](https://github.com/mpjashby/crimemappingdata/) with:

```r
# install.packages("remotes")
remotes::install_github("mpjashby/crimemappingdata")
```

## Available datasets

The following datasets are available, both as:

* R data that can be called using the `data()` function, e.g. `data(aggravated_assaults)`, and
* stand-alone files that can be downloaded in the formats shown below.

See the manual page for each dataset (e.g. `?aggravated_assaults`) for the corresponding stand-alone file URL. Different stand-alone datasets are provided in different file formats (including spatial and non-spatial formats) to give the opportunity for students to practice loading files of different types (e.g. using `readr::read_csv()` or `readxl::read_excel()`).

```{r, echo=FALSE}
# Extract data frame of datasets
data_in_package <- as.data.frame(datasets.load::datasets(package = "crimemappingdata"))
data_in_package$Description <- data_in_package$Title

# Get vector of data files
files <- data.frame(file = dir("inst/extdata"))

# Extract name of datasets without file extensions
files$Item <- regmatches(files$file, regexpr("[a-z\\_]+", files$file))

# Format linked name of dataset
files$Dataset <- paste0(
"[`",
regmatches(files$file, regexpr("[a-z\\_]+", files$file)),
"`](https://pkgs.lesscrime.info/crimemappingdata/reference/",
regmatches(files$file, regexpr("[a-z\\_]+", files$file)),
".html)"
)

# Extract data file extensions
files$Format <- paste0(
"`",
regmatches(files$file, regexpr("\\..*$", files$file)),
"`"
)

# Merge datasets
datasets_data <- merge(data_in_package, files, by = "Item")

knitr::kable(datasets_data[, c("Dataset", "Description", "Format")])
```

Note that gzipped CSV files (with the file extension `.csv.gz`) can be opened using `readr::read_csv()` and functions from other packages, but not `base::read.csv()`.

You can find more details about each dataset in the vignette `vignette("dataset_summary")`.

## Using the data in teaching

For suggestions on how to use the data in this package for teaching, as well as details of each dataset, see the vignette `vignette("teaching")`.

## Data licences

This package is licensed under the MIT Licence, but the individual datasets have been licensed by the data provider using a variety of different open-data licences. Check the manual page for each dataset for details of the relevant licence. Users are responsible for using the data in accordance with the applicable licence for a dataset.