Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit border patrol data to Tidy Tuesday #770

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68,816 changes: 68,816 additions & 0 deletions data/curated/border-patrol/cbp_resp.csv

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions data/curated/border-patrol/cbp_resp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
|variable |class |description |
|:----------------------|:---------|:-------------------------------------|
|fiscal_year |double |The fiscal year the encounter took place |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|month_grouping |character |Allows for comparisons between completed FY months vs. those remaining |
|month_abbv |character |The month the encounter took place (abbreviated) |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|component |character |Who in CBP was involved in the encounter |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|land_border_region |character |The border region in which the encounter occurred; border regions are defined by each component Nationwide numbers are calculated by adding together Northern Land Border, Southwest Land Border, and Other regions |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|area_of_responsibility |character |The field office or sector where the encounter occurred |
|aor_abbv |character |The field office or sector where the encounter occurred (abbreviated) |
|demographic |character |Categories under which individuals were encountered based on factors such as age, admissibility, and relationship |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|citizenship |character |Citizenship of the individual encountered |
|title_of_authority |character |The authority under which the noncitizen was processed |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|encounter_type |character |The category of encounter based on Title of Authority and component (Title 8 for USBP = Apprehensions; Title 8 for OFO = Inadmissibles; Title 42 = Expulsions) |
|encounter_count |double |The number of individuals encountered |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
54,940 changes: 54,940 additions & 0 deletions data/curated/border-patrol/cbp_state.csv

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions data/curated/border-patrol/cbp_state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
|variable |class |description |
|:------------------|:---------|:-------------------------------------|
|fiscal_year |double |The fiscal year the encounter took place |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|month_grouping |character |Allows for comparisons between completed FY months vs. those remaining |
|month_abbv |character |The month the encounter took place (abbreviated) |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|land_border_region |character |The border region in which the encounter occurred; border regions are defined by each component Nationwide numbers are calculated by adding together Northern Land Border, Southwest Land Border, and Other regions |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|state |character |State of the encounter |
|demographic |character |Categories under which individuals were encountered based on factors such as age, admissibility, and relationship |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|citizenship |character |Citizenship of the individual encountered |
|title_of_authority |character |The authority under which the noncitizen was processed |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
|encounter_count |double |The number of individuals encountered |
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions data/curated/border-patrol/cleaning.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
cbp_resp <- bind_rows(
read_csv("https://www.cbp.gov/sites/default/files/assets/documents/2023-Nov/nationwide-encounters-fy20-fy23-aor.csv"),
read_csv("https://www.cbp.gov/sites/default/files/2024-10/nationwide-encounters-fy21-fy24-aor.csv")
) |>
janitor::clean_names() |>
unique()

cbp_state <- bind_rows(
read_csv("https://www.cbp.gov/sites/default/files/assets/documents/2023-Nov/nationwide-encounters-fy20-fy23-state.csv"),
read_csv("https://www.cbp.gov/sites/default/files/2024-10/nationwide-encounters-fy21-fy24-state.csv")
) |>
janitor::clean_names() |>
unique()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions data/curated/border-patrol/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Prepare the dataset

These instructions are for preparing a dataset using the R programming language.
We hope to provide instructions for other programming languages eventually.

If you have not yet set up your computer for submitting a dataset, please see the full instructions at <https://github.com/rfordatascience/tidytuesday/blob/master/.github/pr_instructions.md>.

1. `cleaning.R`: Modify the `cleaning.R` file to get and clean the data.
- Write the code to download and clean the data in `cleaning.R`.
- If you're getting the data from a github repo, remember to use the 'raw' version of the URL.
- This script should result in one or more data.frames, with descriptive variable names (eg `players` and `teams`, not `df1` and `df2`).

2. `saving.R`: Use`saving.R` to save your datasets. This process creates both the `.csv` file(s) and the data dictionary template file(s) for your datasets. **Don't save the CSV files using a separate process because we also need the data dictionaries.**
- Run the first line of `saving.R` to create the functions we'll use to save your dataset.
- Provide the name of your directory as `dir_name`.
- Use `ttsave()` for each dataset you created in `cleaning.R`, substituting the name for the dataset for `YOUR_DATASET_DF`.

3. `{dataset}.md`: Edit the `{dataset}.md` files to describe your datasets (where `{dataset}` is the name of the dataset). These files are created by `saving.R`. There should be one file for each of your datasets. You most likely only need to edit the "description" column to provide a description of each variable.

4. `intro.md`: Edit the `intro.md` file to describe your dataset. You don't need to add a `# Title` at the top; this is just a paragraph or two to introduce the week.

5. Find at least one image for your dataset. These often come from the article about your dataset. If you can't find an image, create an example data visualization, and save the images in your folder as `png` files.

6. `meta.yaml`: Edit `meta.yaml` to provide information about your dataset and how we can credit you. You can delete lines from the `credit` block that do not apply to you.

### Submit your pull request with the data

1. Commit the changes with this folder to your branch. In RStudio, you can do this on the "Git" tab (the "Commit" button).

2. Submit a pull request to <https://github.com/rfordatascience/tidytuesday>. In R, you can do this with `usethis::pr_push()`, and then follow the instructions in your browser.
13 changes: 13 additions & 0 deletions data/curated/border-patrol/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DESCRIPTION

jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
This week we're exploring [U.S. Customs and Border Protection (CBP) encounter data](https://www.cbp.gov/document/stats/nationwide-encounters):

> Encounter data includes U.S. Border Patrol Title 8 apprehensions, Office of Field Operations Title 8 inadmissibles, and all Title 42 expulsions for fiscal years 2020 to date. Data is available for the Northern Land Border, Southwest Land Border, and Nationwide (i.e., air, land, and sea modes of transportation) encounters. Data is extracted from live CBP systems and data sources. Statistical information is subject to change due to corrections, systems changes, change in data definition, additional information, or encounters pending final review. Final statistics are available at the conclusion of each fiscal year.

Thank you to [Tony Galván](https://www.linkedin.com/in/anthony-raul-galvan/) for curating this dataset and providing a [blog post](https://posit.cloud/content/9130042) that explores the data in more detail.
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved

QUESTION?

jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
- How has the implementation (and potential end) of Title 42 affected migration and enforcement trends compared to Title 8 actions?
- What are the key differences in migration patterns and enforcement activity between the Northern and Southwest Land Borders?
- Are there seasonal or year-over-year trends in encounters that can help predict future migration patterns?
19 changes: 19 additions & 0 deletions data/curated/border-patrol/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
title: U.S. Customs and Border Protection (CBP) encounter data
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
article:
title: U.S. Border Patrol Encounters
url: https://posit.cloud/content/9130042
data_source:
title: U.S. Customs and Border Protection
url: https://www.cbp.gov/
images:
# Please include at least one image, and up to three images
- file: inadmissible-aliens-plot.png
alt: >
A bar plot of monthly inadmissible CHNV (citizens of Cuba, Haiti, Nicaragua, and Venezuela) aliens encountered by U.S. Border Patrol agents from 2020 to 2024.
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
credit:
# We want to thank you for curating this dataset! If you do not want a
# particular type of credit, please delete the related line.
post: Tony Galván
jonthegeek marked this conversation as resolved.
Show resolved Hide resolved
linkedin: https://www.linkedin.com/in/anthony-raul-galvan
twitter: @GDataScience1
github: https://github.com/gdatascience
10 changes: 10 additions & 0 deletions data/curated/border-patrol/saving.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Run this
source("data/curated/curation_scripts.R")

# Fill in the name of the folder you created in "curated", then run this.
dir_name <- "border-patrol"

# Run this for each of your datasets, replacing YOUR_DATASET_DF with the name of
# a data.frame from cleaning.R.
ttsave(cbp_resp, dir_name = dir_name)
ttsave(cbp_state, dir_name = dir_name)