Skip to content

Commit

Permalink
Add docs to test compatibility with other classes for #13
Browse files Browse the repository at this point in the history
Former-commit-id: 48654b1
  • Loading branch information
Robinlovelace committed Apr 25, 2022
1 parent da6fa6a commit 48909f4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
30 changes: 30 additions & 0 deletions data-raw/si-classes.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: "Using the si package with different input classes"
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```

```{r setup}
# remotes::install_github("robinlovelace/si")
library(si)
# ?si_predict
```

```{r}
od = si_to_od(si_zones, si_zones, max_dist = 4000)
m = lm(od$origin_all ~ od$origin_bicycle)
od_updated = si_predict(od, m)
class(od_updated)
od_dt = data.table::data.table(od)
class(od_dt)
od_updated_dt = si_predict(od_dt, m)
class(od_updated_dt)
identical(od_updated$interaction, od_updated_dt$interaction)
```

26 changes: 26 additions & 0 deletions data-raw/si-classes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Using the si package with different input classes
================

``` r
# remotes::install_github("robinlovelace/si")
library(si)
# ?si_predict
```

``` r
od = si_to_od(si_zones, si_zones, max_dist = 4000)
#> 1695 OD pairs remaining after removing those with a distance greater than 4000 meters:
#> 15% of all possible OD pairs
m = lm(od$origin_all ~ od$origin_bicycle)
od_updated = si_predict(od, m)
class(od_updated)
#> [1] "sf" "data.frame"
od_dt = data.table::data.table(od)
class(od_dt)
#> [1] "data.table" "data.frame"
od_updated_dt = si_predict(od_dt, m)
class(od_updated_dt)
#> [1] "data.table" "data.frame"
identical(od_updated$interaction, od_updated_dt$interaction)
#> [1] TRUE
```

0 comments on commit 48909f4

Please sign in to comment.