Skip to content

Commit

Permalink
partly addresses #21
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Jul 20, 2020
1 parent 33b24c2 commit 86b4b48
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 59 deletions.
64 changes: 42 additions & 22 deletions API
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
bf_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, sampling.plan = "indepMulti", fixed.margin = "rows", prior.concentration = 1, caption = NULL, output = "null", k = 2, ...)
bf_corr_test(data, x, y, bf.prior = 0.707, caption = NULL, output = "null", k = 2, ...)
bf_expr(bf.df, k = 2, output = "null", caption = NULL, ...)
bf_extractor(bf.object, ...)
bf_meta(data, d = prior, norm, c(mean = 0, sd = 0.3), tau = prior, invgamma, c(shape = 1, scale = 0.15), k = 2, output = "null", caption = NULL, messages = TRUE, ...)
bf_oneway_anova(data, x, y, bf.prior = 0.707, caption = NULL, output = "null", paired = FALSE, k = 2, ...)
bf_ttest(data, x, y = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, caption = NULL, output = "null", k = 2, ...)
corr_objects(data, ci = FALSE, corr.method = "pearson", p.adjust.method = "none", beta = 0.1, k = 2, ...)
expr_anova_bayes(data, x, y, paired = FALSE, bf.prior = 0.707, k = 2, ...)
expr_anova_nonparametric(data, x, y, paired = FALSE, conf.type = "perc", conf.level = 0.95, k = 2, nboot = 100, stat.title = NULL, messages = TRUE, ...)
expr_anova_parametric(data, x, y, paired = FALSE, effsize.type = "unbiased", partial = TRUE, conf.level = 0.95, nboot = 100, var.equal = FALSE, sphericity.correction = TRUE, k = 2, stat.title = NULL, messages = TRUE, ...)
expr_anova_robust(data, x, y, paired = FALSE, tr = 0.1, nboot = 100, conf.level = 0.95, conf.type = "norm", k = 2, stat.title = NULL, messages = TRUE, ...)
expr_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, nboot = 100, paired = FALSE, stat.title = NULL, legend.title = NULL, conf.level = 0.95, conf.type = "norm", bias.correct = TRUE, k = 2, messages = TRUE, ...)
expr_corr_test(data, x, y, nboot = 100, beta = 0.1, type = "pearson", bf.prior = 0.707, conf.level = 0.95, conf.type = "norm", k = 2, stat.title = NULL, messages = TRUE, ...)
expr_meta_bayes(data, d = prior, norm, c(mean = 0, sd = 0.3), tau = prior, invgamma, c(shape = 1, scale = 0.15), k = 2, messages = TRUE, ...)
expr_meta_parametric(data, conf.level = 0.95, k = 2, messages = FALSE, output = "subtitle", caption = NULL, ...)
expr_meta_robust(data, random = "mixture", k = 2, messages = FALSE, ...)
# API for statsExpressions package

## Exported functions

expr_anova_bayes(data, x, y, paired = FALSE, bf.prior = 0.707, k = 2L, ...)
expr_anova_nonparametric(data, x, y, paired = FALSE, conf.type = "perc", conf.level = 0.95, k = 2L, nboot = 100L, stat.title = NULL, ...)
expr_anova_parametric(data, x, y, paired = FALSE, effsize.type = "unbiased", partial = TRUE, conf.level = 0.95, var.equal = FALSE, sphericity.correction = TRUE, k = 2L, stat.title = NULL, ...)
expr_anova_robust(data, x, y, paired = FALSE, tr = 0.1, nboot = 100, conf.level = 0.95, k = 2L, stat.title = NULL, ...)
expr_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, nboot = 100, paired = FALSE, stat.title = NULL, conf.level = 0.95, conf.type = "norm", bias.correct = TRUE, k = 2L, ...)
expr_corr_test(data, x, y, beta = 0.1, type = "parametric", bf.prior = 0.707, conf.level = 0.95, k = 2L, stat.title = NULL, ...)
expr_meta_bayes(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2, messages = TRUE, ...)
expr_meta_parametric(data, conf.level = 0.95, k = 2L, output = "subtitle", caption = NULL, messages = TRUE, ...)
expr_meta_robust(data, random = "mixture", k = 2, messages = TRUE, ...)
expr_onesample_proptest(data, x, y = NULL, counts = NULL, ratio = NULL, nboot = 100, paired = FALSE, stat.title = NULL, conf.level = 0.95, conf.type = "norm", bias.correct = TRUE, k = 2L, ...)
expr_t_bayes(data, x, y, bf.prior = 0.707, paired = FALSE, k = 2, ...)
expr_t_nonparametric(data, x, y, paired = FALSE, k = 2, conf.level = 0.95, conf.type = "norm", nboot = 100, stat.title = NULL, messages = TRUE, ...)
expr_t_onesample(data, x, type = "parametric", test.value = 0, bf.prior = 0.707, robust.estimator = "onestep", effsize.type = "g", effsize.noncentral = TRUE, conf.level = 0.95, conf.type = "norm", nboot = 100, k = 2, stat.title = NULL, messages = TRUE, ...)
expr_t_parametric(data, x, y, paired = FALSE, effsize.type = "g", effsize.noncentral = TRUE, conf.level = 0.95, var.equal = FALSE, k = 2, stat.title = NULL, ...)
expr_t_robust(data, x, y, tr = 0.1, paired = FALSE, nboot = 100, conf.level = 0.95, conf.type = "norm", k = 2, stat.title = NULL, messages = TRUE, ...)
expr_template(no.parameters, stat.title = NULL, statistic.text, stats.df, effsize.text, effsize.df, n, conf.level = 0.95, k = 2, k.parameter = 0, k.parameter2 = 0, n.text = NULL, ...)
expr_t_nonparametric(data, x, y, paired = FALSE, k = 2L, conf.level = 0.95, conf.type = "norm", nboot = 100, stat.title = NULL, ...)
expr_t_onesample(data, x, type = "parametric", test.value = 0, bf.prior = 0.707, robust.estimator = "onestep", effsize.type = "g", conf.level = 0.95, conf.type = "norm", nboot = 100, k = 2L, stat.title = NULL, ...)
expr_t_parametric(data, x, y, paired = FALSE, effsize.type = "g", conf.level = 0.95, var.equal = FALSE, k = 2, stat.title = NULL, ...)
expr_t_robust(data, x, y, tr = 0.1, paired = FALSE, conf.level = 0.95, nboot = 100, k = 2L, stat.title = NULL, ...)
expr_template(no.parameters, stat.title = NULL, statistic.text, stats.df, effsize.text, effsize.df, n, conf.level = 0.95, k = 2L, k.parameter = 0L, k.parameter2 = 0L, n.text = NULL, ...)

## Reexported objects

::%$%
zeallot::%<-%
::%<>%
::%>%
rlang::%|%
rlang::%||%
rlang:::=
tibble::as_tibble
tidyBF::bf_contingency_tab
tidyBF::bf_corr_test
tidyBF::bf_meta
tidyBF::bf_oneway_anova
tidyBF::bf_ttest
correlation::correlation
ipmisc::long_to_wide_converter
metaBMA::prior
ipmisc::set_cwd
ipmisc::signif_column
ipmisc::specify_decimal_p
tibble::tibble
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ VignetteBuilder:
Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
Roxygen: list(markdown = TRUE, roclets = c("rd", "namespace",
"collate", "pkgapi::api_roclet"))
RoxygenNote: 7.1.1
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(bf_corr_test)
export(bf_meta)
export(bf_oneway_anova)
export(bf_ttest)
export(correlation)
export(expr_anova_bayes)
export(expr_anova_nonparametric)
export(expr_anova_parametric)
Expand Down Expand Up @@ -43,7 +44,9 @@ importFrom(WRS2,yuen)
importFrom(WRS2,yuen.effect.ci)
importFrom(WRS2,yuend)
importFrom(broomExtra,easystats_to_tidy_names)
importFrom(broomExtra,glance_performance)
importFrom(broomExtra,tidy)
importFrom(broomExtra,tidy_parameters)
importFrom(correlation,correlation)
importFrom(dplyr,filter)
importFrom(dplyr,inner_join)
Expand Down
45 changes: 10 additions & 35 deletions R/helpers_meta_analysis_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#' @importFrom metafor rma
#' @importFrom dplyr rename_all recode mutate
#' @importFrom tidyBF meta_data_check
#' @importFrom broomExtra tidy_parameters glance_performance
#'
#' @examples
#' \donttest{
Expand Down Expand Up @@ -90,18 +91,8 @@ expr_meta_parametric <- function(data,

# create a dataframe with coefficients
df_tidy <-
coef(summary(meta_res)) %>%
as_tibble(.) %>%
dplyr::rename_all(
.tbl = .,
.funs = dplyr::recode,
se = "std.error",
zval = "statistic",
pval = "p.value",
ci.lb = "conf.low",
ci.ub = "conf.high"
) %>%
dplyr::mutate(.data = ., term = "summary effect")
broomExtra::tidy_parameters(meta_res) %>%
dplyr::mutate(.data = ., term = "Overall")

# preparing the subtitle
subtitle <-
Expand All @@ -120,24 +111,8 @@ expr_meta_parametric <- function(data,

#----------------------- model summary ------------------------------------

df_glance <-
with(
data = meta_res,
expr = tibble(
tau2 = tau2,
se.tau2 = se.tau2,
k = k,
p = p,
m = m,
QE = QE,
QEp = QEp,
QM = QM,
QMp = QMp,
I2 = I2,
H2 = H2,
int.only = int.only
)
)
# model summary
df_glance <- broomExtra::glance_performance(meta_res)

# preparing the subtitle
caption <-
Expand Down Expand Up @@ -166,11 +141,11 @@ expr_meta_parametric <- function(data,
),
env = list(
top.text = caption,
Q = specify_decimal_p(x = df_glance$QE, k = 0L),
df = specify_decimal_p(x = (df_glance$k - 1), k = 0L),
pvalue = specify_decimal_p(x = df_glance$QEp, k = k, p.value = TRUE),
tau2 = specify_decimal_p(x = df_glance$tau2, k = k),
I2 = paste(specify_decimal_p(x = df_glance$I2, k = 2L), "%", sep = "")
Q = specify_decimal_p(x = df_glance$cochran.qe, k = 0L),
df = specify_decimal_p(x = df_glance$df.residual, k = 0L),
pvalue = specify_decimal_p(x = df_glance$p.value.cochran.qe, k = k, p.value = TRUE),
tau2 = specify_decimal_p(x = df_glance$tau.squared, k = k),
I2 = paste(specify_decimal_p(x = df_glance$i.squared, k = 2L), "%", sep = "")
)
)

Expand Down
6 changes: 6 additions & 0 deletions R/reexports.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ tidyBF::bf_oneway_anova
#' @export
#' @importFrom tidyBF prior
tidyBF::prior

# ----------------------- easystats -------------------------------------

#' @export
#' @importFrom correlation correlation
correlation::correlation
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,6 @@
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"fileSize": "4282.836KB",
"fileSize": "4282.428KB",
"readme": "https://github.com/IndrajeetPatil/statsExpressions/blob/master/README.md"
}
3 changes: 3 additions & 0 deletions man/reexports.Rd

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

3 comments on commit 86b4b48

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/movies_wide_long.R:11:1: style: Lines should not be more than 100 characters.

dplyr::select(.data = ., c(title:votes, mpaa:Short)) %>% # eliminate the decile columns r1 through r10
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:12:1: style: Lines should not be more than 100 characters.

dplyr::filter(.data = ., mpaa != "", mpaa != "NC-17") %>% # removing movies without mpaa ratings & NC-17
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:16:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., budget = budget / 1000000) %>% # convert the budget to millions of dollars
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:18:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., NumGenre = as.integer(rowSums(select(., Action:Romance)))) %>% # calculate number of genres a film appears in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/Titanic_full.R:16:10: warning: Avoid 1:nrow(...) expressions, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/helpers_anova_expressions.R:84:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

expr_anova_parametric <- function(data,
^

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/movies_wide_long.R:11:1: style: Lines should not be more than 100 characters.

dplyr::select(.data = ., c(title:votes, mpaa:Short)) %>% # eliminate the decile columns r1 through r10
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:12:1: style: Lines should not be more than 100 characters.

dplyr::filter(.data = ., mpaa != "", mpaa != "NC-17") %>% # removing movies without mpaa ratings & NC-17
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:16:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., budget = budget / 1000000) %>% # convert the budget to millions of dollars
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:18:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., NumGenre = as.integer(rowSums(select(., Action:Romance)))) %>% # calculate number of genres a film appears in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/Titanic_full.R:16:10: warning: Avoid 1:nrow(...) expressions, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/helpers_anova_expressions.R:84:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

expr_anova_parametric <- function(data,
^

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data-raw/movies_wide_long.R:11:1: style: Lines should not be more than 100 characters.

dplyr::select(.data = ., c(title:votes, mpaa:Short)) %>% # eliminate the decile columns r1 through r10
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:12:1: style: Lines should not be more than 100 characters.

dplyr::filter(.data = ., mpaa != "", mpaa != "NC-17") %>% # removing movies without mpaa ratings & NC-17
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:16:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., budget = budget / 1000000) %>% # convert the budget to millions of dollars
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/movies_wide_long.R:18:1: style: Lines should not be more than 100 characters.

dplyr::mutate(.data = ., NumGenre = as.integer(rowSums(select(., Action:Romance)))) %>% # calculate number of genres a film appears in
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

data-raw/Titanic_full.R:16:10: warning: Avoid 1:nrow(...) expressions, use seq_len.

df[rep(1:nrow(df), rep), ]
         ^

R/helpers_anova_expressions.R:84:1: style: functions should have cyclomatic complexity of less than 15, this has 18.

expr_anova_parametric <- function(data,
^

Please sign in to comment.