Skip to content

Commit defe530

Browse files
committed
fix
1 parent 251a524 commit defe530

File tree

11 files changed

+43
-46
lines changed

11 files changed

+43
-46
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,20 @@ Depends:
2121
Imports:
2222
bayestestR,
2323
datawizard,
24-
dplyr,
2524
effectsize,
2625
insight,
2726
lme4,
2827
parameters,
2928
performance,
3029
purrr,
31-
sjlabelled,
3230
sjmisc,
3331
tidyr
3432
Suggests:
3533
brms,
3634
broom,
3735
car,
3836
coin,
37+
dplyr,
3938
ggplot2,
4039
graphics,
4140
MASS,

NAMESPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ importFrom(bayestestR,equivalence_test)
112112
importFrom(datawizard,weighted_mean)
113113
importFrom(datawizard,weighted_median)
114114
importFrom(datawizard,weighted_sd)
115-
importFrom(dplyr,case_when)
116-
importFrom(dplyr,quos)
117-
importFrom(dplyr,select)
118115
importFrom(insight,export_table)
119116
importFrom(insight,format_p)
120117
importFrom(insight,format_value)
@@ -128,7 +125,6 @@ importFrom(purrr,map)
128125
importFrom(purrr,map_dbl)
129126
importFrom(purrr,map_df)
130127
importFrom(purrr,map_lgl)
131-
importFrom(sjlabelled,as_numeric)
132128
importFrom(sjmisc,is_empty)
133129
importFrom(sjmisc,is_float)
134130
importFrom(sjmisc,str_contains)

R/S3-methods.R

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
#' @importFrom dplyr case_when
21
#' @export
32
print.svyglm.nb <- function(x, se = c("robust", "model"), digits = 4, ...) {
43
se <- match.arg(se)
54
sm <- tidy_svyglm.nb(x, digits, v_se = se)[-1, -2]
65

7-
pan <- dplyr::case_when(
8-
sm$p.value < 0.001 ~ "<0.001 ***",
9-
sm$p.value < 0.01 ~ sprintf("%.*f ** ", digits, sm$p.value),
10-
sm$p.value < 0.05 ~ sprintf("%.*f * ", digits, sm$p.value),
11-
sm$p.value < 0.1 ~ sprintf("%.*f . ", digits, sm$p.value),
12-
TRUE ~ sprintf("%.*f ", digits, sm$p.value)
6+
pan <- ifelse(sm$p.value < 0.001, "<0.001 ***",
7+
ifelse(sm$p.value < 0.01, sprintf("%.*f ** ", digits, sm$p.value), # nolint
8+
ifelse(sm$p.value < 0.05, sprintf("%.*f * ", digits, sm$p.value), # nolint
9+
ifelse(sm$p.value < 0.1, sprintf("%.*f . ", digits, sm$p.value), # nolint
10+
sprintf("%.*f ", digits, sm$p.value)
11+
)
12+
)
13+
)
1314
)
1415

1516
sm$p.value <- pan
@@ -30,11 +31,14 @@ print.svyglm.zip <- function(x, se = c("robust", "model"), digits = 4, ...) {
3031
sm <- tidy_svyglm.zip(x, digits, v_se = se)[-1, ]
3132

3233
pan <- ifelse(sm$p.value < 0.001, "<0.001 ***",
33-
ifelse(sm$p.value < 0.01, sprintf("%.*f ** ", digits, sm$p.value),
34-
ifelse(sm$p.value < 0.05, sprintf("%.*f * ", digits, sm$p.value),
35-
ifelse(sm$p.value < 0.1, sprintf("%.*f . ", digits, sm$p.value),
36-
sprintf("%.*f ", digits, sm$p.value)
37-
))))
34+
ifelse(sm$p.value < 0.01, sprintf("%.*f ** ", digits, sm$p.value), # nolint
35+
ifelse(sm$p.value < 0.05, sprintf("%.*f * ", digits, sm$p.value), # nolint
36+
ifelse(sm$p.value < 0.1, sprintf("%.*f . ", digits, sm$p.value), # nolint
37+
sprintf("%.*f ", digits, sm$p.value)
38+
)
39+
)
40+
)
41+
)
3842

3943
sm$p.value <- pan
4044
print(sm, ...)

R/anova_stats.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ aov_stat_summary <- function(model) {
107107
# for mixed models, add information on residuals
108108
if (mm) {
109109
res <- stats::residuals(ori.model)
110-
aov.sum <- dplyr::bind_rows(
110+
aov.sum <- rbind(
111111
aov.sum,
112112
data_frame(
113113
term = "Residuals",

R/auto_prior.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ auto_prior <- function(formula, data, gaussian, locations = NULL) {
8484
y <- data[[y.name]]
8585

8686
# check if response is binary
87-
if (missing(gaussian) && dplyr::n_distinct(y, na.rm = TRUE) == 2) gaussian <- FALSE
87+
if (missing(gaussian) && insight::n_unique(y) == 2) gaussian <- FALSE
8888

89-
if (isTRUE(gaussian) && dplyr::n_distinct(y, na.rm = TRUE) == 2)
89+
if (isTRUE(gaussian) && insight::n_unique(y) == 2)
9090
insight::format_alert("Priors were calculated based on assumption that the response is Gaussian, however it seems to be binary.") # nolint
9191

9292

R/boot_ci.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
#' boot_ci()}
132132
#' @export
133133
boot_ci <- function(data, ..., method = c("dist", "quantile"), ci.lvl = 0.95) {
134+
insight::check_if_installed("dplyr")
134135
# match arguments
135136
method <- match.arg(method)
136137

@@ -160,6 +161,7 @@ boot_ci <- function(data, ..., method = c("dist", "quantile"), ci.lvl = 0.95) {
160161
#' @rdname boot_ci
161162
#' @export
162163
boot_se <- function(data, ...) {
164+
insight::check_if_installed("dplyr")
163165
# evaluate arguments, generate data
164166
.dat <- get_dot_data(data, dplyr::quos(...))
165167

@@ -176,6 +178,7 @@ boot_se <- function(data, ...) {
176178
#' @rdname boot_ci
177179
#' @export
178180
boot_p <- function(data, ...) {
181+
insight::check_if_installed("dplyr")
179182
# evaluate arguments, generate data
180183
.dat <- get_dot_data(data, dplyr::quos(...))
181184

@@ -194,6 +197,7 @@ boot_p <- function(data, ...) {
194197
#' @rdname boot_ci
195198
#' @export
196199
boot_est <- function(data, ...) {
200+
insight::check_if_installed("dplyr")
197201
# evaluate arguments, generate data
198202
.dat <- get_dot_data(data, dplyr::quos(...))
199203

@@ -213,8 +217,8 @@ transform_boot_result <- function(res) {
213217
}
214218

215219

216-
#' @importFrom dplyr select
217220
get_dot_data <- function(x, qs) {
221+
insight::check_if_installed("dplyr")
218222
if (sjmisc::is_empty(qs))
219223
as.data.frame(x)
220224
else

R/gmd.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
#' gmd(efc$e17age)
2424
#' gmd(efc, e17age, c160age, c12hour)
2525
#'
26-
#' @importFrom dplyr quos select
2726
#' @importFrom purrr map_df
2827
#' @importFrom sjmisc is_empty
2928
#' @export
3029
gmd <- function(x, ...) {
31-
# evaluate dots
30+
insight::check_if_installed("dplyr")
31+
# evaluate dots
3232
qs <- dplyr::quos(...)
3333
if (!sjmisc::is_empty(qs)) x <- suppressMessages(dplyr::select(x, !!!qs))
3434

R/weight.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#' table(x)
3939
#' table(weight(x, w))
4040
#'
41-
#' @importFrom sjlabelled as_numeric
4241
#' @export
4342
weight <- function(x, weights, digits = 0) {
4443
# remember if x is numeric
@@ -75,7 +74,9 @@ weight <- function(x, weights, digits = 0) {
7574

7675
# if we have NA values, weighted var is coerced to character.
7776
# coerce back to numeric then here
78-
if (!is.numeric(weightedvar) && x.is.num) weightedvar <- sjlabelled::as_numeric(weightedvar)
77+
if (!is.numeric(weightedvar) && x.is.num) {
78+
weightedvar <- datawizard::to_numeric(weightedvar, dummy_factors = FALSE)
79+
}
7980

8081
# return result
8182
weightedvar

R/wtd_cor.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ weighted_correlation <- function(data, ...) {
77

88
#' @rdname weighted_se
99
#' @export
10-
weighted_correlation.default <- function(data, x, y, weights, ci.lvl = .95, ...) {
11-
if (!missing(ci.lvl) & (length(ci.lvl) != 1 || !is.finite(ci.lvl) || ci.lvl < 0 || ci.lvl > 1))
12-
stop("'ci.lvl' must be a single number between 0 and 1")
10+
weighted_correlation.default <- function(data, x, y, weights, ci.lvl = 0.95, ...) {
11+
if (!missing(ci.lvl) && (length(ci.lvl) != 1 || !is.finite(ci.lvl) || ci.lvl < 0 || ci.lvl > 1))
12+
insight::format_error("'ci.lvl' must be a single number between 0 and 1.")
1313

1414
x.name <- deparse(substitute(x))
1515
y.name <- deparse(substitute(y))
@@ -24,8 +24,8 @@ weighted_correlation.default <- function(data, x, y, weights, ci.lvl = .95, ...)
2424
vars <- c(x.name, y.name, w.name)
2525

2626
# get data
27-
dat <- suppressMessages(dplyr::select(data, !! vars))
28-
dat <- na.omit(dat)
27+
dat <- suppressMessages(data[vars])
28+
dat <- stats::na.omit(dat)
2929

3030
xv <- dat[[x.name]]
3131
yv <- dat[[y.name]]
@@ -37,10 +37,10 @@ weighted_correlation.default <- function(data, x, y, weights, ci.lvl = .95, ...)
3737

3838
#' @rdname weighted_se
3939
#' @export
40-
weighted_correlation.formula <- function(formula, data, ci.lvl = .95, ...) {
40+
weighted_correlation.formula <- function(formula, data, ci.lvl = 0.95, ...) {
4141

42-
if (!missing(ci.lvl) & (length(ci.lvl) != 1 || !is.finite(ci.lvl) || ci.lvl < 0 || ci.lvl > 1))
43-
stop("'ci.lvl' must be a single number between 0 and 1")
42+
if (!missing(ci.lvl) && (length(ci.lvl) != 1 || !is.finite(ci.lvl) || ci.lvl < 0 || ci.lvl > 1))
43+
insight::format_error("'ci.lvl' must be a single number between 0 and 1.")
4444

4545
vars <- all.vars(formula)
4646

@@ -50,7 +50,7 @@ weighted_correlation.formula <- function(formula, data, ci.lvl = .95, ...) {
5050
}
5151

5252
# get data
53-
dat <- suppressMessages(dplyr::select(data, !! vars))
53+
dat <- suppressMessages(data[vars])
5454
dat <- na.omit(dat)
5555

5656
xv <- dat[[vars[1]]]

R/wtd_ttest.R

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ weighted_ttest.default <- function(data, x, y = NULL, weights, mu = 0, paired =
2828
vars <- c(x.name, y.name, w.name)
2929

3030
# get data
31-
dat <- suppressMessages(dplyr::select(data, !! vars))
31+
dat <- suppressMessages(data[vars])
3232
dat <- na.omit(dat)
3333

3434
if (sjmisc::is_empty(dat) || nrow(dat) == 1) {
35-
warning("Too less data to compute t-test.")
35+
insight::format_alert("Too less data to compute t-test.")
3636
return(NULL)
3737
}
3838

@@ -96,15 +96,7 @@ weighted_ttest.formula <- function(formula, data, mu = 0, paired = FALSE, ci.lvl
9696
nx <- length(xv)
9797
ny <- length(yv)
9898

99-
labs <- sjlabelled::get_labels(
100-
data[[vars[2]]],
101-
attr.only = FALSE,
102-
values = "p",
103-
drop.na = TRUE,
104-
drop.unused = TRUE
105-
)
106-
107-
weighted_ttest_helper(xv, yv, wx, wy, nx, ny, mu, paired, alternative, ci.lvl, vars[1], vars[2], labs)
99+
weighted_ttest_helper(xv, yv, wx, wy, nx, ny, mu, paired, alternative, ci.lvl, vars[1], vars[2], vars[2])
108100
}
109101

110102

R/xtab_statistics.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#' )
107107
#' @export
108108
crosstable_statistics <- function(data, x1 = NULL, x2 = NULL, statistics = c("auto", "cramer", "phi", "spearman", "kendall", "pearson", "fisher"), weights = NULL, ...) {
109+
insight::check_if_installed("dplyr")
109110
# match arguments
110111
statistics <- match.arg(statistics)
111112

0 commit comments

Comments
 (0)