How has household size and configuration changed in the last 125 years? We answer this question using publicly available American Community Survey and Decennial Census data, accessed via IPUMS, alongside the analytic tools available in the demographR package.
The average American at the turn of the 20th century lived in a household with nearly
6 individuals. With some exceptions, that value has since been on the decline, with the
rate of decrease in household size much slower in recent decades than during most of
the 20th century. As of 2023, the average American lives in a household of 3.33 persons.

For experienced users who just want to get the project running right away. If you have trouble following these steps, please follow the Detailed Start guide below.
-
Navigate to the directory where you want the project to be saved and clone both required repos side by side
cd your/path/to/parent/directorygit clone https://github.com/lorae/households-over-the-years households-over-the-years git clone https://github.com/lorae/demographr demographr
-
Enter the main project
cd households-over-the-years -
Copy the environment file and edit it with your own IPUMS API key
cp example.Renviron .Renviron # (Windows PowerShell: Copy-Item example.Renviron .Renviron) # IMPORTANT: open .Renviron and replace "your_ipums_api_key" with your actual key
-
Restore dependencies and run the analysis
Open
households-over-the-years.Rprojin your preferred IDE, then in the R console:renv::restore() source("run-all.R")
Detailed instructions for how to fully install and run this project code on your computer.
These steps will allow you to install the code on your computer that runs this project and set up the environment so that it mimics the environment on which the code was developed.
-
Clone the repo: Open a terminal on your computer. Navigate to the directory you would like to be the parent directory of the repo, then clone the repo.
MacOS/Linux:
cd your/path/to/parent/directorygit clone https://github.com/lorae/households-over-the-years households-over-the-years
Windows:
cd your\path\to\parent\directorygit clone https://github.com/lorae/households-over-the-years households-over-the-years
-
Open the R project: Navigate into the directory, now located at
your/path/to/parent/directory/households-over-the-years. Openhouseholds-over-the-years.Rprojusing your preferred IDE for R. (We use R Studio.)Every subsequent time you work with the project code, you should always open the
households-over-the-years.Rprojfile at the beginning of your work session. This will avoid common issues with broken file paths or an incorrect working directory. -
Initialize R environment: Install all the dependencies (packages) needed to make the code run on your computer.
First, ensure you have the package manager,
renv, installed. Run the following in your R console:install.packages("renv") # Safe to run, even if you're not sure if you already have renv
library("renv")Then restore the project:
renv::restore()
-
Clone the sibling repo,
demographr: This project makes use of a bundle of functions that are unit-tested and generalized in a package calleddemographr. Clone this repo in the same parent directory where you clonedimmigrant-households.🛑 Important: Do not clone this inside of the
immigrant-householdsrepo: instead, it should be a sibling: it should contained in the same folder structure ashouseholds-over-the-years.MacOS/Linux:
cd your/path/to/parent/directorygit clone https://github.com/lorae/demographr demographr
Windows:
cd your\path\to\parent\directorygit clone https://github.com/lorae/demographr demographr
The IPUMS Terms of Use precludes us from directly sharing the raw microdata extract, however, the data used in this analysis is freely available after setting up an IPUMS USA account, and we provide an automated script that writes the API call and downloads the exact data used in this analysis.
-
Copy the file
example.Renvironto a new file named.Renvironin the project root directory. You can do this manually or use the following terminal commands:MacOS/Linux:
cp example.Renviron .Renviron
Windows (use PowerShell):
Copy-Item example.Renviron .Renviron -
Set up your IPUMS USA API key: If you don't already have one, set up a free account on IPUMS USA. Use the new account to login to the IPUMS API key webpage. Copy your API key from this webpage.
-
Open
.Renviron(‼️ notexample.Renviron!) and replaceyour_ipums_api_keywith your actual key. Do not include quotation marks. R will automatically load.Renvironwhen you start a new session. This keeps your API key private and separate from the codebase.🛑 Important:
.Renvironis listed in.gitignore, so it will not be tracked or uploaded to GitHub — butexample.Renvironis tracked, so do not put your actual API key in the example file.
The code for this project is stored in the src folder:
-
scripts/: executable analysis scripts -
utils/: accessory modules (functions), subject to unit tests
-
Run all code by sourcing the
run-all.Rscript in your R console:source("run-all.R")
MIT License (see LICENSE file).
This repository accompanies ongoing research on households and household size.
For now, please cite as:
Households Over the Years: Replication Code and Analysis. Maintained by Lorae Stojanovic and Peter Hepburn.
GitHub. https://github.com/lorae/households-over-the-years