Open Online R Stream - 2021/05/20
News, Resources, Errata/Additions

Wolfgang Viechtbauer
Maastricht University


R Related News

  • R version 4.1.0 has been released
    codename “Camp Pontanezen”
    What are those version names?
    https://stackoverflow.com/questions/13478375/is-there-any-authoritative-documentation-on-r-release-nicknames
    https://static.wikia.nocookie.net/peanuts/images/c/c3/19860212.gif
  • R now contains a native ‘pipe’ operator

    # nested functions
    sqrt(log(5))
    
    # using the pipe operator
    5 |> log() |> sqrt()
  • R now also contains a way to quickly create ‘anonymous functions’

    # load metafor package
    library(metafor)
    
    # copy the BCG vaccine data to 'dat'
    dat <- dat.bcg
    dat
    
    # compute log risk ratios and corresponding sampling variances
    dat <- escalc(measure="RR", ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat)
    dat
    
    # fit random-effects model to a subset of studies
    rma(yi, vi, data=dat, subset=alloc=="random")
    
    # another way of doing the same thing using pipes and an anonymous function
    dat |> subset(alloc=="random") |> (function(d) rma(yi, vi, data=d))()
    
    # use the new shorthand syntax to create the anonymous function
    dat |> subset(alloc=="random") |> (\(d) rma(yi, vi, data = d))()

R Related Resources

  • The Epidemiologist R Handbook
    https://epirhandbook.com

Errata / Additions

  • I have updated the code for the example forest plot with subgroups
    https://www.metafor-project.org/doku.php/plots:forest_plot_with_subgroups