Skip to content

Commit e6212f3

Browse files
committed
register calc_impl() s3 methods (closes #523)
1 parent 7d437a3 commit e6212f3

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

NAMESPACE

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(calc_impl,Chisq)
4+
S3method(calc_impl,F)
5+
S3method(calc_impl,correlation)
6+
S3method(calc_impl,count)
7+
S3method(calc_impl,diff_in_means)
8+
S3method(calc_impl,diff_in_medians)
9+
S3method(calc_impl,diff_in_props)
10+
S3method(calc_impl,function_of_props)
11+
S3method(calc_impl,mean)
12+
S3method(calc_impl,median)
13+
S3method(calc_impl,odds_ratio)
14+
S3method(calc_impl,prop)
15+
S3method(calc_impl,ratio_of_means)
16+
S3method(calc_impl,ratio_of_props)
17+
S3method(calc_impl,sd)
18+
S3method(calc_impl,slope)
19+
S3method(calc_impl,sum)
20+
S3method(calc_impl,t)
21+
S3method(calc_impl,z)
322
S3method(fit,infer)
423
S3method(get_p_value,default)
524
S3method(get_p_value,infer_dist)

R/calculate.R

+19
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,16 @@ calc_impl_one_f <- function(f) {
295295
}
296296
}
297297

298+
#' @export
298299
calc_impl.mean <- calc_impl_one_f(mean)
299300

301+
#' @export
300302
calc_impl.median <- calc_impl_one_f(stats::median)
301303

304+
#' @export
302305
calc_impl.sum <- calc_impl_one_f(sum)
303306

307+
#' @export
304308
calc_impl.sd <- calc_impl_one_f(stats::sd)
305309

306310
calc_impl_success_f <- function(f, output_name) {
@@ -327,20 +331,23 @@ calc_impl_success_f <- function(f, output_name) {
327331
}
328332
}
329333

334+
#' @export
330335
calc_impl.prop <- calc_impl_success_f(
331336
f = function(response, success, ...) {
332337
mean(response == success, ...)
333338
},
334339
output_name = "proportion"
335340
)
336341

342+
#' @export
337343
calc_impl.count <- calc_impl_success_f(
338344
f = function(response, success, ...) {
339345
sum(response == success, ...)
340346
},
341347
output_name = "count"
342348
)
343349

350+
#' @export
344351
calc_impl.F <- function(type, x, order, ...) {
345352
x %>%
346353
dplyr::summarize(
@@ -350,6 +357,7 @@ calc_impl.F <- function(type, x, order, ...) {
350357
)
351358
}
352359

360+
#' @export
353361
calc_impl.slope <- function(type, x, order, ...) {
354362
x %>%
355363
dplyr::summarize(
@@ -359,6 +367,7 @@ calc_impl.slope <- function(type, x, order, ...) {
359367
)
360368
}
361369

370+
#' @export
362371
calc_impl.correlation <- function(type, x, order, ...) {
363372
x %>%
364373
dplyr::summarize(
@@ -403,12 +412,16 @@ calc_impl_diff_f <- function(f, operator) {
403412
}
404413
}
405414

415+
#' @export
406416
calc_impl.diff_in_means <- calc_impl_diff_f(mean, operator = `-`)
407417

418+
#' @export
408419
calc_impl.diff_in_medians <- calc_impl_diff_f(stats::median, operator = `-`)
409420

421+
#' @export
410422
calc_impl.ratio_of_means <- calc_impl_diff_f(mean, operator = `/`)
411423

424+
#' @export
412425
calc_impl.Chisq <- function(type, x, order, ...) {
413426
resp_var <- response_name(x)
414427

@@ -464,6 +477,7 @@ calc_impl.Chisq <- function(type, x, order, ...) {
464477
)
465478
}
466479

480+
#' @export
467481
calc_impl.function_of_props <- function(type, x, order, operator, ...) {
468482
col <- response_expr(x)
469483
success <- attr(x, "success")
@@ -501,14 +515,17 @@ calc_impl.function_of_props <- function(type, x, order, operator, ...) {
501515
res
502516
}
503517

518+
#' @export
504519
calc_impl.diff_in_props <- function(type, x, order, ...) {
505520
calc_impl.function_of_props(type, x, order, operator = `-`, ...)
506521
}
507522

523+
#' @export
508524
calc_impl.ratio_of_props <- function(type, x, order, ...) {
509525
calc_impl.function_of_props(type, x, order, operator = `/`, ...)
510526
}
511527

528+
#' @export
512529
calc_impl.odds_ratio <- function(type, x, order, ...) {
513530
col <- response_expr(x)
514531
success <- attr(x, "success")
@@ -524,6 +541,7 @@ calc_impl.odds_ratio <- function(type, x, order, ...) {
524541
dplyr::select(stat)
525542
}
526543

544+
#' @export
527545
calc_impl.t <- function(type, x, order, ...) {
528546
if (theory_type(x) == "Two sample t") {
529547
x <- reorder_explanatory(x, order)
@@ -556,6 +574,7 @@ calc_impl.t <- function(type, x, order, ...) {
556574
df_out
557575
}
558576

577+
#' @export
559578
calc_impl.z <- function(type, x, order, ...) {
560579
# Two sample proportions
561580
if (theory_type(x) == "Two sample props z") {

0 commit comments

Comments
 (0)