-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
118 lines (82 loc) · 4.04 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
---
title: "mop: Mobility Oriented-Parity Metric"
author: "Marlon E. Cobos, Hannah L. Owens, Jorge Soberón, A. Townsend Peterson"
output:
github_document:
toc: yes
toc_depth: 3
---
```{r, include = FALSE}
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
fig.path = "man/figures/README-", out.width = "100%")
```
<!-- badges: start -->
[![R build
status](https://github.com/marlonecobos/mop/workflows/R-CMD-check/badge.svg)](https://github.com/marlonecobos/mop/actions)
<!-- badges: end -->
<hr>
The package `mop` contains a set of tools to perform the Mobility Oriented-Parity (MOP) metric, which helps to compare a set of conditions of reference versus another set of of interest. The main goals of the MOP metric are to explore conditions in the set of interest that are non-analogous to those in the reference set, and to quantify how different conditions in the set of interest are. The tools included here help to identify conditions outside the rages of the reference set with greater detail than in earlier implementations. These tools are based on the methods proposed by [Owens et al. (2013)](https://doi.org/10.1016/j.ecolmodel.2013.04.011).
<br>
## Installation
### Install stable version from CRAN
To install the stable version of `mop` use:
```{r install_cran, eval=FALSE}
install.packages("mop")
```
<br>
### Install development version
Before installing the development version of `mop`, make sure to obtain the compilation tools required: [Rtools](https://cran.r-project.org/bin/windows/Rtools/) for Windows, [Xcode](https://apps.apple.com/us/app/xcode/id497799835?mt=12) for Mac, and `ggc` or similar compilers in Linux, see examples [here](https://gcc.gnu.org/install/) or [here](https://www.makeuseof.com/how-to-install-c-compiler-linux/).
After that, you can install the development version of `mop` from its [GitHub repository](https://github.com/marlonecobos/mop) with:
```{r install_gh, eval=FALSE}
# install.packages("remotes")
remotes::install_github("marlonecobos/mop")
```
<br>
## Example
The following are basic examples of how to use the main function of the package. First, load the package and some example data.
```{r load}
# package
library(mop)
# data
## current conditions
reference_layers <- terra::rast(system.file("extdata", "reference_layers.tif",
package = "mop"))
## future conditions
layers_of_interest <- terra::rast(system.file("extdata",
"layers_of_interest.tif",
package = "mop"))
# plot the data
## variables to represent current conditions
terra::plot(reference_layers)
## variables to represent future conditions
terra::plot(layers_of_interest)
```
<br>
### Running analyses
The code below helps to run analyses with all the details implemented in the function. To see more basic options and what they imply, check the function documentation with `help(mop)`. Parallel processing is allowed via arguments of this function.
```{r basic}
# analysis
mop_basic_res <- mop(m = reference_layers, g = layers_of_interest,
type = "detailed", calculate_distance = TRUE,
where_distance = "all", distance = "euclidean",
scale = TRUE, center = TRUE)
# summary
summary(mop_basic_res)
# print results
mop_basic_res
```
<br>
### Plotting results
Below are some example plots of the results that can be obtained from analysis with `mop`.
```{r plots}
# difference between set of conditions of interest and the reference set
terra::plot(mop_basic_res$mop_distances)
# basic identification of non-analogous results
terra::plot(mop_basic_res$mop_basic)
# how many variables have non-analogous conditions
terra::plot(mop_basic_res$mop_simple)
# combinations of variables with non-analogous conditions towards high values
terra::plot(mop_basic_res$mop_detailed$towards_high_combined)
# combinations of variables with non-analogous conditions towards low values
terra::plot(mop_basic_res$mop_detailed$towards_low_combined)
```