-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
117 lines (94 loc) · 5.13 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
---
output:
rmarkdown::github_document:
html_preview: no
---
```{r, include = FALSE}
devtools::load_all()
knitr::opts_chunk$set(fig.path = "man/figures/README-", fig.align = "center")
```
<!--- README.md is generated from README.Rmd. Please edit that file -->
# prioritizrdata: Conservation Planning Datasets
[![lifecycle](https://img.shields.io/badge/Lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![R-CMD-check-Ubuntu](https://img.shields.io/github/actions/workflow/status/prioritizr/prioritizrdata/R-CMD-check-ubuntu.yaml?branch=main&label=Ubuntu)](https://github.com/prioritizr/prioritizrdata/actions)
[![R-CMD-check-Windows](https://img.shields.io/github/actions/workflow/status/prioritizr/prioritizrdata/R-CMD-check-windows.yaml?branch=main&label=Windows)](https://github.com/prioritizr/prioritizrdata/actions)
[![R-CMD-check-macOS](https://img.shields.io/github/actions/workflow/status/prioritizr/prioritizrdata/R-CMD-check-macos.yaml?branch=main&label=macOS)](https://github.com/prioritizr/prioritizrdata/actions)
[![Documentation](https://img.shields.io/github/actions/workflow/status/prioritizr/prioritizrdata/documentation.yaml?branch=main&label=Documentation)](https://github.com/prioritizr/prioritizrdata/actions)
[![Coverage Status](https://img.shields.io/codecov/c/github/prioritizr/prioritizrdata?label=Coverage)](https://app.codecov.io/gh/prioritizr/prioritizrdata/branch/main)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/prioritizrdata)](https://CRAN.R-project.org/package=prioritizrdata)
The _prioritizrdata R_ package is a supplemental package that contains example datasets for conservation planning. It is intended to be used alongside the [_prioritizr R_ package](https://prioritizr.net).
## Overview
This package contains the following datasets.
* **Tasmania dataset**: Conservation planning dataset for Tasmania, Australia.
* **Salt Spring Island dataset**: Conservation planning dataset for Tasmania, Australia.
* **Washington dataset**: Conservation planning dataset for Washington, The United States of America.
## Installation
The latest official version of the _prioritizrdata R_ package can be installed using the following _R_ code.
```{r, eval = FALSE}
install.packages("prioritizrdata", repos = "https://cran.rstudio.com/")
```
Alternatively, the latest development version can be installed using the following code. Please note that while developmental versions may contain additional features not present in the official version, they may also contain coding errors.
```{r, eval = FALSE}
if (!require(devtools))
install.packages("devtools")
devtools::install_github("prioritizr/prioritizrdata")
```
## Citation
Please cite the _prioritizrdata R_ package when using it in publications. To cite the latest official version, please use:
```{r, include = FALSE}
# define helpers
is_rel_version <- function(x) {
length(strsplit(as.character(x), ".", fixed = TRUE)[[1]]) == 3
}
package_version_year <- function(x) {
if (x %in% rownames(available.packages())) {
return(live_package_version_year(x))
} else {
return(archive_package_version_year(x))
}
}
live_package_version_year <- function(x) {
# fetch data
d <- paste0("http://cran.r-project.org/web/packages/", x, "/DESCRIPTION")
d <- read.dcf(url(d))
c(
as.character(d[, "Version"]),
as.character(format(as.POSIXct(d[, "Date/Publication"]), "%Y"))
)
}
archive_package_version_year <- function(x) {
# fetch data (copied from remotes R package)
tf <- tempfile(fileext = ".gz")
on.exit(unlink(tf), add = TRUE)
download.file(tf, url = sprintf("%s/src/contrib/Meta/archive.rds", repo))
con <- gzfile(tf, "rb")
on.exit(close(con), add = TRUE)
d <- readRDS(con)[[x]]
# extract version
rel_version <- basename(rownames(d))
rel_version <- sapply(strsplit(rel_version, "_", fixed = TRUE), `[[`, 2)
rel_version <- sapply(strsplit(rel_version, ".tar", fixed = TRUE), `[[`, 1)
rel_version <- max(rel_version)
# extract year
rel_year <- as.character(max(format(d[, "mtime"], "%Y")))
# return year version
c(rel_version, rel_year)
}
# get version numbers and years
dev_version_year <- c(
as.character(packageDescription("prioritizrdata")$Version),
format(Sys.time(), "%Y")
)
if (is_rel_version(dev_version_year[[1]])) {
rel_version_year <- dev_version_year
} else {
rel_version_year <- package_version_year("prioritizrdata")
}
```
```{r, echo = FALSE, results = "asis", comment = ""}
cat(paste0("> Hanson JO, Schuster R, Morrell N, Strimas-Mackey M, Watts ME, Arcese P, Bennett J, Possingham HP (", rel_version_year[[2]] ,"). prioritizrdata: Conservation Planning Datasets. R package version ", rel_version_year[[1]],". Available at https://CRAN.R-project.org/package=prioritizrdata.\n"))
```
Alternatively, to cite the latest development version, please use:
```{r, echo = FALSE, results = "asis", comment = ""}
cat(paste0("> Hanson JO, Schuster R, Morrell N, Strimas-Mackey M, Watts ME, Arcese P, Bennett J, Possingham HP (", dev_version_year[[2]],"). prioritizrdata: Conservation Planning Datasets. R package version ", dev_version_year[[1]], ". Available at https://github.com/prioritizr/prioritizrdata.\n"))
```