-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve conflict Merge branch 'main' of https://github.com/RSGInc/tra…
- Loading branch information
Showing
11 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
title: "Creating user-specified geographic summaries" | ||
description: > | ||
output: html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Creating user-specified geographic summaries} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = TRUE, message = FALSE) | ||
library(travelSurveyTools) | ||
library(data.table) | ||
library(tigris) | ||
``` | ||
|
||
### Creating summaries by geographic variables using hts_summary | ||
|
||
`hts_summary` can summarize geographic variables. | ||
|
||
```{r, county_income, echo=TRUE, eval=TRUE} | ||
DT = hts_prep_data(summarize_var = 'income_detailed', summarize_by = 'home_county', data = test_data) | ||
output = hts_summary(prepped_dt = DT$cat, summarize_var = 'income_detailed', summarize_by = 'home_county') | ||
factorize_df(output$summary$unwtd, vals_df = value_labels, value_label_colname = 'label') | ||
``` | ||
|
||
### Using spatial_join to join together separate shapefiles | ||
|
||
`spatial_join` can link together multiple geographies. | ||
|
||
```{r, spatial_join, echo=TRUE, eval=TRUE} | ||
states = states() | ||
hh = join_spatial( | ||
hh, | ||
dplyr::select(states, home_state = NAME), | ||
id_col = 'hh_id', | ||
lon_col = 'home_lon', | ||
lat_col = 'home_lat', | ||
largest = TRUE) | ||
hh[, .N, home_state] | ||
``` |