-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME.Rmd
158 lines (106 loc) · 5.25 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
## Overview
sppt is an [R](https://www.r-project.org) package that implements several
Spatial Point Pattern Tests. This package started with Martin Andresen's
original 'sppt' that is published [here](http://jrc.sagepub.com/content/48/1/58)
and elsewhere.
The Spatial Point Pattern Tests in this package measure the degree of similarity
at the local level between two spatial pointpatterns and are area-based tests.
These tests are not for the purpose of testing point
patterns with the null hypotheses of random, uniform, or clustered
distributions, but may be used to compare a particular point pattern with
these distributions. One advantage is that it can be performed for
a number of different area boundaries using the same original point datasets.
## Version
The most recent version of the package is:
> Steenbeek, W., Vandeviver, C. Andresen, M.A., Malleson, N., Wheeler, A. *sppt: Spatial Point Pattern Test*. R package version 0.2.3. URL: https://github.com/wsteenbeek/sppt
An archive of older versions of the package can be found here: https://github.com/wsteenbeek/sppt-archive.
## Installation
You can install the package from this
[GitHub repository](https://github.com/wsteenbeek/sppt). You first need to
install the [remotes](https://CRAN.R-project.org/package=remotes) package.
```{r, eval = FALSE}
install.packages("remotes")
```
Then install sppt using the `install_github` function in the
[remotes](https://CRAN.R-project.org/package=remotes) package.
```{r, eval = FALSE}
remotes::install_github("wsteenbeek/sppt")
```
## Example
Spatial objects areas.sp, points1.sp, and points2.sp, are included in the
package. For example, you can think of these as neighborhoods and the locations
where crimes occur in two different years.
```{r, eval = TRUE, warning = FALSE, message = FALSE}
library(sppt)
plot(areas.sp)
points(points1.sp, col="blue", pch = 19)
points(points2.sp, col="red", pch = 15)
```
The original function within the sppt package is also called `sppt`:
```{r, eval = TRUE}
set.seed(93255) # set seed for reproducibility
output <- sppt(points1.sp, points2.sp, areas.sp)
```
Two other functions were added in February 2018. `sppt_boot()`:
```{r, eval = TRUE}
set.seed(93255) # set seed for reproducibility
output2 <- sppt_boot(points1.sp, points2.sp, areas.sp)
```
and `sppt_diff()`:
```{r, eval = TRUE}
set.seed(93255) # set seed for reproducibility
output3 <- sppt_diff(points1.sp, points2.sp, areas.sp)
```
You can see the results of the test by inspecting the SpatialPolygonsDataFrame, for example:
```{r, eval = TRUE}
output@data
```
The global S-values can be outputted directly using `summary_sppt()`:
```{r, eval = TRUE}
summary_sppt(output)
```
## Vignettes
The package includes vignettes explaining the sppt procedure in more detail;
a worked example of a toy dataset and actual crime data; a comparison
between this R package and an existing Java application that has been written by
[Nick Malleson](http://nickmalleson.co.uk/); and the new functions `sppt_boot()`
and `sppt_diff()`.
By far the easiest way to view the vignettes are these direct links, courtesy of the [GitHub HTML Preview service](http://htmlpreview.github.io/):
1. [Introduction to Spatial Point Pattern Test](http://htmlpreview.github.io/?https://github.com/wsteenbeek/sppt/blob/master/doc/sppt_intro.html)
2. [Comparing R vs Java](http://htmlpreview.github.io/?https://github.com/wsteenbeek/sppt/blob/master/doc/sppt_comparison.html)
3. [Proportion difference tests](http://htmlpreview.github.io/?https://github.com/wsteenbeek/sppt/blob/master/doc/sppt_diff.html)
If instead you want to access the vignettes from R itself you need to take a few additional steps, because `remotes::install_github()` does not build vignettes by default to save time and because it may require additional packages.
1. Install the rmarkdown package with `install.packages("rmarkdown")`
2. [Install pandoc](http://johnmacfarlane.net/pandoc/installing.html) (and afterwards restart your computer)
3. Then, install the package again but force building of the vignettes using `remotes::install_github("wsteenbeek/sppt", build_vignettes = TRUE, force = TRUE)`. This will take a few minutes.
Afterwards, you should be able to view which vignettes are available using:
```{r, eval = FALSE}
browseVignettes("sppt")
```
To directly read the vignettes rather than going through `browseVignettes("sppt")` you can use:
```{r, eval = FALSE}
vignette("sppt_intro", package = "sppt")
vignette("sppt_comparison", package = "sppt")
vignette("sppt_diff", package = "sppt")
```
## License
This package is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 3, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose. See the GNU
General Public License for more details.
A copy of the GNU General Public License, version 3, is available at
<https://www.r-project.org/Licenses/GPL-3>