This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by: https://github.com/mjskay/uncertainty-examples/blob/master/diamond_plot.md | |
# to see if we can abuse metafor::forest() and metafor::addpoly() to create such a plot | |
library(palmerpenguins) | |
library(metafor) | |
set.seed(1234) | |
dat <- penguins | |
dat <- dat[!is.na(dat$sex),] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# means, SDs, and group sizes | |
m1 <- 52 | |
m2 <- 40 | |
sd1 <- 6 | |
sd2 <- 4 | |
n1 <- 20 | |
n2 <- 40 | |
# pooled SD | |
sdp <- ((n1-1)*sd1^2 + (n2-1)*sd2^2) / (n1 + n2 - 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
genjournal <- function() { | |
x1 <- sample(c("American Journal of", "Austin Journal of", "Annals of", "Archives of", "International Journal of", "Journal of", "Open Journal of", "World Journal of", "Insights Journal of", "Short Reports of", ""), 1) | |
x2 <- sample(c("Clinical", "Child & Adolescent", "Family", "Current", "Preventive", "Emergency", "Novel", ""), 1) | |
x3 <- sample(c("Medicine", "Health Care", "Biomedical Science", "Case Reports", "Nursing Studies", "Surgery", "Medical Case Reports", "Obstetrics", "Gynecology", "Family Medicine", "Primary Care", "Nursing", "Psychiatry", "Pulmonology", "Images", "Biology", "Behavioral Science", "Public Health", "Nursing Practice", "Respiratory Care", "Cancer", "Neurology", "Musculoskeletal Disorders", "Epidemiology", "Cardiology", "Vascular Medicine", "Hematology", "Imaging", "Microbiology", "Infectious Diseases", "Oncology", "Neuroinflammation", "Neurodegenerative Diseases", "Gerontology", "Addiction", "Rehabilitation Medicine", "Translational Medicine", "Images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################ | |
library(metafor) | |
library(boot) | |
dat <- dat.crede2010 | |
dat <- escalc(measure="ZCOR", ri=ri, ni=ni, data=dat, subset=criterion=="grade") | |
############################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################ | |
library(metafor) | |
library(ape) | |
############################################################################ | |
# read the documentation for this dataset | |
help(dat.moura2021) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> ############################################################################ | |
> | |
> # A comparison of for-loops versus apply() and sapply() for 1) computing the | |
> # row means in a matrix and 2) for computing the means of all elements in a | |
> # list. For task 1), we can also examine the performance of rowMeans() as a | |
> # specialized / vectorized function and for task 2), we can also compare | |
> # sapply() with vapply() (note: vapply() was added in version R-2.12.0). Also, | |
> # for the for-loop, we can examine what the impact is of pre-allocating the | |
> # vector in which to store the results versus 'growing' the vector in each | |
> # iteration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################ | |
R version 2.5.0 (2007-04-23) | |
Copyright (C) 2007 The R Foundation for Statistical Computing | |
ISBN 3-900051-07-0 | |
R is free software and comes with ABSOLUTELY NO WARRANTY. | |
You are welcome to redistribute it under certain conditions. | |
Type 'license()' or 'licence()' for distribution details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
message("A message") | |
warning("A warning") | |
stop("An error") | |
globalCallingHandlers( | |
message = function(c) { | |
style <- crayon::make_style("white") | |
c$message <- style(c$message) | |
message(c) | |
invokeRestart("muffleMessage") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################################ | |
# During the course, we will make use of a number of add-on packages for R. | |
# Ideally, you should install these packages before the course (then you don't | |
# have to bother with installing packages during the course). The code below | |
# can be used to install each of the packages one by one. So, just run each | |
# command below (e.g., by copy-pasting it into R) line by line. | |
# If you are asked to create a 'personal library', choose 'yes'. If you are | |
# asked to choose a 'CRAN mirror', just select the default one (which is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iters <- 1000 | |
ns <- iters - 500 | |
nl <- iters - ns + 1 | |
rmin <- 2.4 | |
rmax <- 4 | |
rn <- 5000 | |
x <- rep(0,iters) |
NewerOlder