Skip to content


Repository files navigation

A Primer on Binary Logistic Regression (in R)

This repository contains the statistical source code for the logistic regression primer by Jenine K. Harris. If you are new to R, follow the instructions below to install the appropriate software and download the source code.

(Update January 24, 2022) The repository now also contains the Stata code and data files to reproduce the analyses. The files are called lab 2 data.dta and Lab 2 do These files were contributed by Suhail A. R. Doi and Tawanda Chivese of the College of Medicine at Qatar University in Doha, Qatar.

Getting Started in R

R is a statistical software that is free, open-source, and can run on most operating systems. This means that anyone in the world with access to a computer and the internet can use it and anyone in the world can contribute to the development of new tools in R.

R can do everything that paid statistical software like SPSS and SAS can do, and often more! Analysis of data on job openings and other metrics shows that R is increasingly included as a desired or required skill, often surpassing traditional closed source software like SPSS and SAS. R is particularly great for data management and developing amazing data visualizations.

Install R and RStudio

R is the software and RStudio is the IDE (Interactive Development Environment) that makes R easier to use. Install R before you install RStudio because RStudio will look for R during installation.

First, download and install R:

  • Click the download R link on the R Project for Statistical Computing website
  • Choose one of the options from the CRAN Mirrors list (it doesn't matter which one!)
  • Click on the download that is appopropriate for your operating system, Linux, Mac, or Windows; if you are not given this option, go back to the CRAN Mirrors and try a different one
  • Find the link for install R for the first time and click on it
  • Click on the the Download R link on the page that opens
  • Use the installer that downloads to install R

Second, download and install RStudio:

  • Go to the RStudio downloads page
  • Click on the DOWNLOAD button under the RStudio Desktop column on the downloads page
  • Choose the Download for the operating system you have and click on it
  • Use the installer that downloads to install RStudio

Download and save R code file

Download the code file:

  • Click on the green Code button toward the top of this GitHub page
  • Choose Download ZIP
  • Unzip the downloaded zip file and save all the files in a single folder on your computer

Install the tidyverse, finalfit, knitr, car, odds.n.ends, and table1 packages

Open RStudio and follow these instructions :

  • Click on the Tools menu
  • Type tidyverse, table1, finalfit, knitr, car, odds.n.ends into the dialog box that opens
  • Click install (R will do stuff for a while, this might look like errors but is fine)

Open, highlight, and run the downloaded R code file


No description, website, or topics provided.






No releases published