-
Notifications
You must be signed in to change notification settings - Fork 1
Using the story maker R script to create tables
The story maker script allows you to create one, two, or three dimensional tables using fields from the household travel survey. It is built for people with at least an introductory to intermediate knowledge of both travel survey and R. The code connects to data of your choosing, but currently is set to the 2017/2019 data on Elmer. It takes care of any weighting or joining for you. You simply feed in where you want the tables to output, where the code is running, and which data items you want to summarize. It uses similar functions from the Shiny App Data Explorer, but you don't need to click through so much to get what you want; you can just type.
The code is part of this repository: https://github.com/psrc/travel-studies To get started, clone or download the repository. The code for story making specifically is in this directory: https://github.com/psrc/travel-studies/tree/master/2019/story_maker
You need R installed, and it is recommended to use RStudio to help you navigate the code. The code uses the following libraries: data.table, tidyverse, DT, openxlsx, odbc, DBI.
- Create an R project in the local directory where you have downloaded the code that originages here: https://github.com/psrc/travel-studies/tree/master/2019/story_maker
- Make a new .R file to do your work. At the top of the file, source these two .R files:
source('global.R') source('travel_crosstab.R')
- In this .R file, next set the directories where you are running the code, for example:
#where you are running your R code **wrkdir **<- "C:/Users/SChildress/Documents/GitHub/travel-studies/2019/story_maker"
#where you want to output tables **file_loc **<- 'C:/Users/SChildress/Documents/HHSurvey/race_story'
- Start summarizing!
There are two functions that you can use: summarize_simple_tables and summarize_cross_tables