Skip to content

Commit

Permalink
Merge pull request #8 from stscl/dev
Browse files Browse the repository at this point in the history
update `sshicm()`
  • Loading branch information
SpatLyu authored Dec 17, 2024
2 parents ad86711 + de0eb36 commit 452f891
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion R/sshicm.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' cinc = sf::read_sf(system.file("extdata/cinc.gpkg",package = "sshicm"))
#' sshicm(THEFT_D ~ .,cinc,type = "IN")
#' }
sshicm = \(formula, data, type = 'IC', seed = 42,
sshicm = \(formula, data, type = c("IC","IN"), seed = 42,
permutation_number = 999, bin_method = "Sturges"){
formulavar = sdsfun::formula_varname(formula,data)
yvec = data[,formulavar[[1]],drop = TRUE]
Expand All @@ -29,6 +29,7 @@ sshicm = \(formula, data, type = 'IC', seed = 42,
}
xtbl = dplyr::select(data,dplyr::all_of(formulavar[[2]]))

type = match.arg(type)
if (type == "IC"){
res = purrr::map_dfr(xtbl,
\(.x) sshic(yvec,.x,seed,
Expand Down
22 changes: 11 additions & 11 deletions vignettes/sshicm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ library(sshicm)
baltim = sf::read_sf(system.file("extdata/baltim.gpkg",package = "sshicm"))
sshicm(PRICE ~ .,baltim,type = "IC")
## # A tibble: 5 × 3
## Variable Ic Pv
## <chr> <dbl> <dbl>
## 1 AC 0.447 0.00501
## 2 PATIO 0.162 0.643
## 3 FIREPL 0.135 0.657
## 4 DWELL 0.124 0.716
## Variable Ic Pv
## <chr> <dbl> <dbl>
## 1 AC 0.223 0
## 2 PATIO 0.162 0.643
## 3 FIREPL 0.135 0.657
## 4 DWELL 0.124 0.716
## 5 CITCOU 0.0898 0.988
```

Expand All @@ -119,11 +119,11 @@ sshicm(THEFT_D ~ .,cinc,type = "IN")
ntds = gdverse::NTDs
sshicm(incidence ~ watershed + elevation + soiltype,data = ntds)
## # A tibble: 3 × 3
## Variable Ic Pv
## <chr> <dbl> <dbl>
## 1 elevation 0.329 0.0100
## 2 watershed 0.140 0.0901
## 3 soiltype 0.121 0.0250
## Variable Ic Pv
## <chr> <dbl> <dbl>
## 1 watershed 0.284 0.0100
## 2 elevation 0.135 0.0531
## 3 soiltype 0.0825 0.133
```


Expand Down

0 comments on commit 452f891

Please sign in to comment.