-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
66 lines (49 loc) · 1.71 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
---
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%"
)
```
# tidyrgeoda <img src="man/figures/logo.png" align="right" height="100"/>
<!-- badges: start -->
![CRAN](https://www.r-pkg.org/badges/version/tidyrgeoda)
![r-universe](https://spatlyu.r-universe.dev/badges/tidyrgeoda)
<!-- badges: end -->
The goal of **tidyrgeoda** is to provide an interface for **rgeoda** to integrate with **sf** objects and the **tidyverse**.
## Installation
You can install the development version of **tidyrgeoda** from [github](https://github.com/SpatLyu/tidyrgeoda):
``` r
# install.packages("devtools")
devtools::install_github("SpatLyu/tidyrgeoda",
build_vignettes = T,
dep = T)
```
or install **tidyrgeoda** from [r-universe](https://spatlyu.r-universe.dev/tidyrgeoda):
```r
install.packages('tidyrgeoda',
repos = c("https://spatlyu.r-universe.dev",
"https://cran.rstudio.com/"),
dep = TRUE)
```
## Example
This is a basic example which shows you how to use `tidyrgeoda` to create a `spatial weight matrix` and calculate the `local_moran`:
```{r example}
library(sf)
library(tidyverse)
library(tidyrgeoda)
guerry = read_sf(system.file("extdata","Guerry.shp",package = "rgeoda"))
guerry %>%
mutate(lisa = st_local_moran(.,'Crm_prs',
wt = st_weights(.,'contiguity',queen = T))) %>%
select(lisa) -> g_lisa
g_lisa
ggplot(data = g_lisa) +
geom_sf(aes(fill = lisa),lwd = .1,color = 'grey') +
scale_fill_lisa()
```