Skip to content

A workshop, 'Open data and reproducibility: R Markdown, dashboards and Binder', led by Pablo Bernabeu and Eirini Zormpa at the UK Cognitive Linguistics Conference (https://www.ukclc2020.com/pre-conference).

License

Notifications You must be signed in to change notification settings

pablobernabeu/UKCLC2020-workshop-Open-data-and-reproducibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 

Repository files navigation

Open data and reproducibility: R Markdown, dashboards and Binder

A workshop at the UK Cognitive Linguistics Conference, on 26 July 2020 (https://www.ukclc2020.com/pre-conference), led by Pablo Bernabeu and Eirini Zormpa.

The methods for disseminating research in cognitive linguistics, and other fields, are advancing. Papers now include more and more supplementary materials. This shift has been facilitated by burgeoning technologies and available training. Another major contributor was the replication crisis in psychology. Nowadays, researchers customarily examine the extra materials with new studies. These materials are available to non-academics, too. Newer tools are available, notably based on open-source software. Let’s look at three tools around the R language.

[The sections and times were adjusted during the workshop.]

You’re welcome to post any questions in issues.


R Markdown   75 min

Keep your input and output in check using R Markdown (https://rmarkdown.rstudio.com/).

Examples

Text styling with Markdown, HTML and CSS   30 min

Running code   15 min

Cross-references   10 min

  • Background

  • Live demo: Pablo, 5 minutes

    Using this for figures and tables.

  • Task: Modifying code, 5 minutes

    Create a standard R Markdown document in RStudio, turn the summary() into a table by wrapping it in knitr::kable(), add cross-references to the table and the plot, and knit (please retry any of those steps and ask us any questions if necessary).

Creating a paper   10 min

Publishing to RPubs   10 min

  • Background: https://rpubs.com/

  • Live demo: Pablo, 5 minutes

  • Task: Free creation, 5 minutes


Dashboards and web applications   55 min

On a further step in reproducible, open data, we will learn how to publish dashboards online presenting data in the form of plots and tables. These all-reproducible dashboards are displayed as websites; thus, they can include hyperlinks and downloadable files. Some of the R packages used are ‘rmarkdown,' ‘knitr,’ ‘ggplot,’ ‘plotly,’ ‘flexdashboard,’ and ‘shiny.’ The aim is to practise with different forms of dashboards (Flexdashboard, Shiny, Flexdashboard-Shiny) and the suitable hosting platforms (personal website, RPubs, Binder, Shinyapps, and custom servers).

Examples

Creating a Flexdashboard (interactive R Markdown)   20 min

  • Background: https://rmarkdown.rstudio.com/flexdashboard/

  • Live demo: Pablo, 10 minutes

  • Task: 10 minutes

    Create a flexdashboard document and use ggplotly() from plotly package (code below adapted from RStudio)

    df <- data.frame(
    gp = factor(rep(letters[1:3], each = 10)),
      y = rnorm(30)
    )
    ds <- do.call(rbind, lapply(split(df, df$gp), function(d) {
      data.frame(mean = mean(d$y), sd = sd(d$y), gp = d$gp)
    }))
    
    # The summary data frame ds is used to plot larger red points on top
    # of the raw data. Note that we don't need to supply `data` or `mapping`
    # in each layer because the defaults from ggplot() are used.
    ggplotly(ggplot(df, aes(gp, y)) +
      geom_point() +
      geom_point(data = ds, aes(y = mean), colour = 'red', size = 3))
    

    and kable() from knitr package (see also DT package)

    kable(summary(cars))
    

Creating a web application using Shiny   10 min

Combining Flexdashsboard and Shiny for best results   15 min

Publishing to shinyapps.io   10 min


Binder   15 min

Did you know that you can enable public access to your data and analysis code in RStudio, on a simple internet browser? There are various options for this, and one of the most accessible ones is Binder (https://mybinder.org). We’ll look at Binder’s requirements and possibilities.

RStudio environment example: http://mybinder.org/v2/gh/binder-examples/r/master?urlpath=rstudio Dashboard environment example: https://mybinder.org/v2/gh/pablobernabeu/Modality-switch-effects-emerge-early-and-increase-throughout-conceptual-processing/3863a3bfa79a4f765f3dac39007802b6f5e2bd9d?urlpath=shiny/Shiny-app/

Creating a Binder repo for R coding   15 min


The timing includes a 10-minute introduction, two 10-minute breaks and a 5-minute conclusion.

Real data and code of varying complexity will be used. Basic and advanced R users are welcome. 

Please sign up to RStudio Cloud (https://rstudio.cloud/), which may become useful if you encounter any issues in your local R.

Also suggested: 

installing or updating R (https://www.r-project.org/) and RStudio (https://rstudio.com/products/rstudio/download/); perusing the links here; having some data and R code ready, preferably in a Github repository.


CC BY licence

About

A workshop, 'Open data and reproducibility: R Markdown, dashboards and Binder', led by Pablo Bernabeu and Eirini Zormpa at the UK Cognitive Linguistics Conference (https://www.ukclc2020.com/pre-conference).

Topics

Resources

License

Stars

Watchers

Forks