Skip to content

Commit 87ba09d

Browse files
committed
simplify
1 parent 0078633 commit 87ba09d

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

R/plot.dw_data_tabulate.R

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,24 @@ plot.datawizard_tables <- function(
3535
...
3636
) {
3737
show_na <- insight::validate_argument(show_na, c("if_any", "always", "never"))
38+
# setup argument list
39+
fun_args <- list(
40+
label_values = label_values,
41+
show_na = show_na,
42+
na_label = na_label,
43+
error_bar = error_bar,
44+
ci = ci,
45+
color_fill = color_fill,
46+
color_error_bar = color_error_bar
47+
)
48+
# plot cross table data
3849
if (length(x) == 1L) {
39-
plot.datawizard_table(
40-
x[[1]],
41-
label_values = label_values,
42-
show_na = show_na,
43-
na_label = na_label,
44-
error_bar = error_bar,
45-
ci = ci,
46-
color_fill = color_fill,
47-
color_error_bar = color_error_bar
48-
)
50+
do.call(plot.datawizard_table, c(list(x[[1]]), fun_args))
4951
} else {
5052
lapply(
5153
x,
5254
plot.datawizard_table,
53-
label_values = label_values,
54-
show_na = show_na,
55-
na_label = na_label,
56-
error_bar = error_bar,
57-
ci = ci,
58-
color_fill = color_fill,
59-
color_error_bar = color_error_bar
55+
fun_args
6056
)
6157
}
6258
}

0 commit comments

Comments
 (0)