forked from stscl/gdverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
81 lines (63 loc) · 1.91 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
---
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%",
warning = FALSE,
message = FALSE
)
```
# gdverse <img src="man/figures/logo.png" align="right" height="120"/>
<!-- badges: start -->
[![CRAN](https://www.r-pkg.org/badges/version/gdverse)](https://CRAN.R-project.org/package=gdverse)
[![r-universe](https://spatlyu.r-universe.dev/badges/gdverse)](https://spatlyu.r-universe.dev/gdverse)
<!-- badges: end -->
The goal of gdverse is to support the geodetector model and its variants.
## Installation
You can install the development version of gdverse from [GitHub](https://github.com/SpatLyu/gdverse) with:
``` r
# install.packages("devtools")
devtools::install_github("SpatLyu/gdverse",build_vignettes = T,dep = T)
```
or install `gdverse` from `r-universe`:
```r
install.packages('gdverse', repos='https://spatlyu.r-universe.dev')
```
### Load data and package
```{r example_gdverse}
library(sf)
library(terra)
library(tidyverse)
library(gdverse)
fvcpath = "https://github.com/SpatLyu/rdevdata/raw/main/FVC.tif"
fvc = terra::rast(paste0("/vsicurl/",fvcpath))
fvc = terra::aggregate(fvc,fact = 5)
fvc = as_tibble(terra::as.data.frame(fvc,na.rm = T))
head(fvc)
```
### OPGD model
```{r}
set.seed(12345678)
tictoc::tic()
fvc_opgd = opgd(fvc ~ ., data = fvc, discnum = 2:15,
discvar = names(select(fvc,-c(fvc,lulc))),
cores = 6, type = 'factor')
tictoc::toc()
fvc_opgd
```
### RGD model
To run `RGD`,remember to set up your python dependence, see `RGD` vignette to get more details.
```{r}
reticulate::use_condaenv('geocompy')
tictoc::tic()
fvc_rgd = rgd(fvc ~ ., data = fvc, discnum = 15,
discvar = names(select(fvc,-c(fvc,lulc))),
cores = 6, type = 'factor')
tictoc::toc()
fvc_rgd
```