Skip to content

Commit d0acab4

Browse files
committed
rename as_slide_computation func input to avoid name collisions
1 parent a317594 commit d0acab4

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

R/utils.R

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ assert_sufficient_f_args <- function(f, ...) {
198198
#'
199199
#' @source https://github.com/r-lib/rlang/blob/c55f6027928d3104ed449e591e8a225fcaf55e13/R/fn.R#L343-L427
200200
#'
201-
#' @param x A function, one-sided formula, or quosure.
201+
#' @param .f A function, one-sided formula, or quosure.
202202
#'
203203
#' If a **function** and `calc_ref_time_value` is `FALSE`, the function is
204204
#' returned as-is, with no modifications. If `calc_ref_time_value` is
@@ -253,15 +253,15 @@ assert_sufficient_f_args <- function(f, ...) {
253253
#' f_rhs is_formula caller_arg caller_env
254254
#'
255255
#' @noRd
256-
as_slide_computation <- function(x,
256+
as_slide_computation <- function(.f,
257257
before,
258258
calc_ref_time_value = FALSE,
259259
...,
260-
arg = caller_arg(x),
260+
arg = caller_arg(.f),
261261
call = caller_env()) {
262262
# A quosure is a type of formula, so be careful with the order and contents
263263
# of the conditional logic here.
264-
if (is_quosure(x)) {
264+
if (is_quosure(.f)) {
265265
if (calc_ref_time_value) {
266266
f_wrapper = function(.x, .group_key, ...) {
267267
.ref_time_value = min(.x$time_value) + before
@@ -275,7 +275,7 @@ as_slide_computation <- function(x,
275275
data_mask$.x = .x
276276
data_mask$.group_key = .group_key
277277
data_mask$.ref_time_value = .ref_time_value
278-
rlang::eval_tidy(x, data_mask)
278+
rlang::eval_tidy(.f, data_mask)
279279
}
280280
return(f_wrapper)
281281
}
@@ -292,32 +292,32 @@ as_slide_computation <- function(x,
292292
data_mask$.x = .x
293293
data_mask$.group_key = .group_key
294294
data_mask$.ref_time_value = .ref_time_value
295-
rlang::eval_tidy(x, data_mask)
295+
rlang::eval_tidy(.f, data_mask)
296296
}
297297
return(f_wrapper)
298298
}
299299

300-
if (is_function(x) || is_formula(x)) {
301-
if (is_function(x)) {
300+
if (is_function(.f) || is_formula(.f)) {
301+
if (is_function(.f)) {
302302
# Check that `f` takes enough args
303-
assert_sufficient_f_args(x, ...)
304-
fn <- x
303+
assert_sufficient_f_args(.f, ...)
304+
fn <- .f
305305
}
306306

307-
if (is_formula(x)) {
308-
if (length(x) > 2) {
307+
if (is_formula(.f)) {
308+
if (length(.f) > 2) {
309309
Abort(sprintf("%s must be a one-sided formula", arg),
310310
class = "epiprocess__as_slide_computation__formula_is_twosided",
311-
epiprocess__x = x,
311+
epiprocess__f = .f,
312312
call = call)
313313
}
314314

315-
env <- f_env(x)
315+
env <- f_env(.f)
316316
if (!is_environment(env)) {
317317
Abort("Formula must carry an environment.",
318318
class = "epiprocess__as_slide_computation__formula_has_no_env",
319-
epiprocess__x = x,
320-
epiprocess__x_env = env,
319+
epiprocess__f = .f,
320+
epiprocess__f_env = env,
321321
arg = arg, call = call)
322322
}
323323

@@ -326,7 +326,7 @@ as_slide_computation <- function(x,
326326
.x = quote(..1), .y = quote(..2), .z = quote(..3),
327327
. = quote(..1), .group_key = quote(..2), .ref_time_value = quote(..3)
328328
)
329-
fn <- new_function(args, f_rhs(x), env)
329+
fn <- new_function(args, f_rhs(.f), env)
330330
fn <- structure(fn, class = c("epiprocess_slide_computation", "function"))
331331
}
332332

@@ -343,10 +343,10 @@ as_slide_computation <- function(x,
343343
return(fn)
344344
}
345345

346-
Abort(sprintf("Can't convert a %s to a slide computation", class(x)),
346+
Abort(sprintf("Can't convert a %s to a slide computation", class(.f)),
347347
class = "epiprocess__as_slide_computation__cant_convert_catchall",
348-
epiprocess__x = x,
349-
epiprocess__x_class = class(x),
348+
epiprocess__f = .f,
349+
epiprocess__f_class = class(.f),
350350
arg = arg,
351351
call = call)
352352
}

0 commit comments

Comments
 (0)