How has the size and configuration of U.S. immigrant households changed since the 1970s? We examine this question, building upon our previous work on American headship rate and housing supply as well as the demographics of American households.
Forthcoming.
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 repo
cd your/path/to/parent/directory -
Clone both required repos side by side
git clone https://github.com/lorae/immigrant-households immigrant-households git clone https://github.com/lorae/demographr demographr
-
Enter the main project
cd immigrant-households -
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
immigrant-households.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/immigrant-households immigrant-households
Windows:
cd your\path\to\parent\directorygit clone https://github.com/lorae/immigrant-households immigrant-households
-
Open the R project: Navigate into the directory, now located at
your/path/to/parent/directory/immigrant-households. Openimmigrant-households.Rprojusing your preferred IDE for R. (We use R Studio.)Every subsequent time you work with the project code, you should always open the
immigrant-households.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 asimmigrant-households.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 immigrant household configurations.
For now, please cite as:
Immigrant Households: Replication Code and Analysis. Maintained by Lorae Stojanovic and Peter Hepburn.
GitHub. https://github.com/lorae/immigrant-households