Tutorial: How to randomize in R

tutorial randomization methods

How to use several randomizr functions to randomize individuals and clusters to study arms with and without blocking.

true
09-27-2019


Tutorial: https://learn.themethodsection.com/tutorial/randomize

Source: Github


I teach a class session on experimental designs, and in my prep this week I was looking for a brief activity that would give students an opportunity for hands-on learning. In the process of searching the web for inspiration, I had a flashback to early RA days where I was asked to randomize participants into groups and had no idea how to do it for real.

I remembered seeing something recently about randomization in the Declare Design suite of tools, so I headed over to the site and found the randomizr package for R. The site includes a tutorial that incorporates another randomization package I know called blockTools, so I had the basis for a tutorial idea.

There are several great options for creating interactive tutorials. Ines Montani developed a Binder-based framework for her spaCy course that she adapted for R users. Karthik Ram created holepunch for turning R notebooks into interactive RStudio instances with your project and all its dependencies.

I decided to go with RStudio’s learnr package for creating interactive tutorials. It’s easy to use and I think the layout is intuitive for learners.

I used #learnr from @rstudio to create my first tutorial on randomization. Today's session was about experimental designs, so I was looking for a short activity to accompany the readings. #ghrbook #rstats 1/https://t.co/9BUl88RcKC pic.twitter.com/firPJD5kO1

— Eric Green (@ericpgreen) September 26, 2019

The tutorial I created shows you how to use several randomizr functions to randomize individuals and clusters to study arms with and without blocking. Learnr lets you change the code and see what happens without having to spin up your own instance, which I think is key for students who don’t have a background in R. It’s a great platform for sparking interest in statistical programming.

Citation

For attribution, please cite this work as

Green (2019, Sept. 27). The Method Section: Tutorial: How to randomize in R. Retrieved from https://blog.themethodsection.com/posts/2019-08-24-tutorial-how-to-randomize-in-r/

BibTeX citation

@misc{green2019tutorial:,
  author = {Green, Eric},
  title = {The Method Section: Tutorial: How to randomize in R},
  url = {https://blog.themethodsection.com/posts/2019-08-24-tutorial-how-to-randomize-in-r/},
  year = {2019}
}