-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] apa_print()-methods for metafor #299
base: devel
Are you sure you want to change the base?
Conversation
Resync to master
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this started, Emily. It's a great start! I'll add a couple of comments, know that this is work in progress. Let me know if you want to continue work on this.
#' } | ||
#' @family apa_print | ||
#' | ||
apa_print.metafor <- function( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm missing something, for S3-method dispatch to work this functions needs to be named after the S3 class it is ment to operate on. In this case, I think, it should be either the specific rma.uni
or more general rma
depending on how general this method should be. Right?
|
||
apa_res <- papaja:::apa_print_container() | ||
|
||
apa_res$estimate <- paste0("$", est_name, "$ = ", round(x$b, x$digits[["est"]]), " $95\\% CI$ = $[", round(x$ci.lb, digits = x$digits[["ci"]]), "$, $", round(x$ci.ub, digits = x$digits[["ci"]]), "]$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In terms of a general workflow I try to assemble the table
element first and build the rest from it. Do you think this could be a sensible approach here too? It may simplify maintenance and may expose commonalities among functions that could be used further reuse code across methods.
apa_res <- papaja:::apa_print_container() | ||
|
||
apa_res$estimate <- paste0("$", est_name, "$ = ", round(x$b, x$digits[["est"]]), " $95\\% CI$ = $[", round(x$ci.lb, digits = x$digits[["ci"]]), "$, $", round(x$ci.ub, digits = x$digits[["ci"]]), "]$") | ||
apa_res$estimate <- setNames(apa_res$estimate, row.names(x$beta)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I never use setNames()
but really should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest it's just copied from how the variable names are set in metafor itself.
apa_res$table$estimate <- broom::tidy(x) | ||
|
||
apa_res$table$heterogeneity <- broom::glance(x) | ||
names(apa_res$table$heterogeneity) <- c("k", "measure", "method", "I$^2$", "H$^2$", "$\\tau^2$", "$\\tau^2$ se", "Cochran Q$_e$", "Cochran Q$_e$ $p$", "Cochran Q$_m$", "Cochran Q$_m$ $p$") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a nice next step would be to add variable labels using variable_labels()
.
This is the first attempt at adding a apa_print function for metafor (rma) objects. This will handle both univariate meta-analysis and meta-regression models.
The formatting of the output and documentations needs improvement but this should give you an idea of where we're up to after the hackathon at SIPS2019.