Skip to content

Commit

Permalink
Complete switch to tidyeval, progress on #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Apr 21, 2022
1 parent 3c05538 commit babf5ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
6 changes: 3 additions & 3 deletions R/si_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
#' n = destination_all, d = distance_euclidean)
#' head(od_output)
#' plot(od$distance_euclidean, od_output$interaction)
#' od_pconst = si_calculate(od, fun = fun, beta = 0.3, O = origin_all, n = destination_all,
#' d = distance_euclidean, constraint_p = origin_all)
#' od_pconst = si_calculate(od, fun = fun, beta = 0.3, O = origin_all,
#' n = destination_all, d = distance_euclidean, constraint_p = origin_all)
#' plot(od_pconst$distance_euclidean, od_pconst$interaction)
#' plot(od_pconst["interaction"], logz = TRUE)
si_calculate = function(od, fun, constraint_p, ...) {
dots = rlang::enquos(...)
od = mutate(od, interaction = fun(!!!dots))
od = dplyr::mutate(od, interaction = fun(!!!dots))
if (!missing(constraint_p)) {
od_grouped = dplyr::group_by(od, .data$O)
od_grouped = dplyr::mutate(
Expand Down
15 changes: 8 additions & 7 deletions man/si_calculate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions vignettes/si.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ Note that the output has duplicate columns: `si_to_od()` joins data from the ori
A simplistic SIM can be created just based on the distance between points:

```{r unconstrained1}
si_power = function(od, beta) {
(od[["distance_euclidean"]] / 1000)^beta
}
od_calculated = si_calculate(od_sim, fun = si_power, beta = -0.8)
si_power = function(d, beta) (d / 1000)^beta
od_calculated = si_calculate(
od_sim,
fun = si_power,
d = distance_euclidean,
beta = -0.8
)
plot(od_calculated["interaction"], logz = TRUE)
```

Expand Down Expand Up @@ -178,6 +181,7 @@ od_originating = od_joined %>%
od_constrained_p = si_calculate(
od_originating,
fun = si_power,
d = distance_euclidean,
beta = -0.8,
constraint_p = originating_per_zone
)
Expand Down

0 comments on commit babf5ea

Please sign in to comment.