[like] Sulabh Aryal reacted to your message:
________________________________
From: Charles Purvis <clpurvis(a)att.net>
Sent: Thursday, August 14, 2025 1:04:08 AM
To: The Census Transportation Products Program Community of Practice/Users discussion and
news list <ctpp(a)listserv.transportation.org>
Subject: [CTPP News] Sample R scripts to pull 2017-2021 CTPP data
I’m extremely grateful to Stacey Bricka of MacroSys and Shichen Feng of the Fresno COG to
provide insights and help in curing my logjam/frustrations.
I’ve uploaded a 10 example R-script to pull data from the CTPP 2017-2021 data for Parts 1,
2, and 3 at various geographic levels.
Here it is:
<https://github.com/chuckpurvis/r_scripts/blob/main/ctpp1721_examples_1.R>
[r_scripts.png]
r_scripts/ctpp1721_examples_1.R at main ·
chuckpurvis/r_scripts<https://github.com/chuckpurvis/r_scripts/blob/main…
github.com<https://github.com/chuckpurvis/r_scripts/blob/main/ctpp1721_e…
I recommend having the CTPP Data Portal open in a web browser to help assist in selecting
tables and understanding geographic levels associated with any of the tables.
Most challenging was my attempt to pull tract-to-tract worker flow for my region. I think
there is an upper limit on the number of records that can be pulled in the API, somewhere
between 50,000 records and 5,000,000 records.
Next steps:
1. renaming variable names to be more mnemonic and memorable.
2. attaching GIS files using either tidycensus or the r package tigris.
3. mapping all of the cool patterns
4. summarizing tract-to-tract worker flows to county-to-county level, to ascertain data
loss due to lack of secondary allocation.
5. There probably should NOT be any data loss in any place-to-county or county-to-place
summary levels. Check this.
Hope this is of interest and use to the community.
cheers,
Chuck Purvis
Hayward, California
or contact me directly, at: clpurvis@att.net<mailto:clpurvis@att.net>
# # # # #