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

add interactive plot #63

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Binary file modified .DS_Store
Binary file not shown.
70 changes: 35 additions & 35 deletions .Rhistory
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
limits = c(0.04, 0.1),
labels = scales::percent) +
scale_y_continuous(expand = expansion(mult = c(0, 0.002)),
breaks = c(0, 0.01, 0.02, 0.03, 0.04, 0.05),
limits = c(0, 0.05),
labels = scales::percent) +
labs(x = "Seasonally-adjusted unemployment rate",
y = "Seasonally-adjusted vacancy rate") +
scatter_grid()
# Chunk 22: slope-plot
# https://www.bls.gov/lau/
library(ggrepel)
unemployment <- tibble(
time = c("October 2009", "October 2009", "October 2009", "August 2017", "August 2017", "August 2017"),
rate = c(7.4, 7.1, 10.0, 3.9, 3.8, 6.4),
state = c("Maryland", "Virginia", "Washington, D.C.", "Maryland", "Virginia", "Washington, D.C.")
)
label <- tibble(label = c("October 2009", "August 2017"))
october <- filter(unemployment, time == "October 2009")
august <- filter(unemployment, time == "August 2017")
unemployment %>%
mutate(time = factor(time, levels = c("October 2009", "August 2017")),
state = factor(state, levels = c("Washington, D.C.", "Maryland", "Virginia"))) %>%
ggplot() +
geom_line(aes(time, rate, group = state, color = state), show.legend = FALSE) +
geom_point(aes(x = time, y = rate, color = state)) +
labs(subtitle = "Unemployment Rate") +
theme(axis.ticks.x = element_blank(),
axis.title.x = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank(),
axis.text.y = element_blank(),
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.x = element_blank(),
axis.line = element_blank()) +
geom_text_repel(data = october, mapping = aes(x = time, y = rate, label = as.character(rate)), nudge_x = -0.06) +
geom_text_repel(data = august, mapping = aes(x = time, y = rate, label = as.character(rate)), nudge_x = 0.06)
Expand Down Expand Up @@ -510,3 +475,38 @@ palette_urbn_main[1:4]
palette_urbn_spacegray[1:5]
# Chunk 59: System Info and Package Versioning
sessionInfo()
renv::status()
# load ggsankey package
remotes::install_github("davidsjoberg/ggsankey")
# create a dummy dataset of housing status
df <- data_frame(entry_status = c(rep("Housed", 7), rep("Unhoused", 15), rep("Staying w/ Family", 8)),
exit_status = c(rep("Housed", 15), rep("Unhoused", 2), rep("Staying w/ Family", 13))) %>%
# transform the data frame into the proper format for the sankey plot
make_long(entry_status, exit_status) %>%
# recode the labels to be cleaner in the plot
mutate(x = recode(x, entry_status = "Prior Housing Status", exit_status = "Exit Housing Status"),
next_x = recode(next_x, entry_status = "Prior Housing Status", exit_status = "Exit Housing Status"))
library(tidyverse)
# load ggsankey package
remotes::install_github("davidsjoberg/ggsankey")
library(ggsankey)
# create a dummy dataset of housing status
df <- data_frame(entry_status = c(rep("Housed", 7), rep("Unhoused", 15), rep("Staying w/ Family", 8)),
exit_status = c(rep("Housed", 15), rep("Unhoused", 2), rep("Staying w/ Family", 13))) %>%
# transform the data frame into the proper format for the sankey plot
make_long(entry_status, exit_status) %>%
# recode the labels to be cleaner in the plot
mutate(x = recode(x, entry_status = "Prior Housing Status", exit_status = "Exit Housing Status"),
next_x = recode(next_x, entry_status = "Prior Housing Status", exit_status = "Exit Housing Status"))
# create sankey plot
ggplot(df, aes(x = x,
next_x = next_x,
node = node,
next_node = next_node,
fill = factor(node),
label = node)) +
geom_sankey(flow.alpha = 0.5, node.color = 1, show.legend = FALSE) +
# add labels to plot and style
geom_sankey_label(size = 3.5, color = 1, fill = "white") +
theme_sankey(base_size = 16)+
labs(x = NULL)
Binary file modified .Rproj.user/.DS_Store
Binary file not shown.
Binary file modified .Rproj.user/4C8EE3A7/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .Rproj.user/4C8EE3A7/pcs/source-pane.pper
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"activeTab": 5
"activeTab": 0
}
6 changes: 3 additions & 3 deletions .Rproj.user/4C8EE3A7/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"left": {
"splitterpos": 157,
"splitterpos": 246,
"topwindowstate": "NORMAL",
"panelheight": 682,
"windowheight": 720
},
"right": {
"splitterpos": 426,
"topwindowstate": "NORMAL",
"splitterpos": 424,
"topwindowstate": "MINIMIZE",
"panelheight": 682,
"windowheight": 720
}
Expand Down
2 changes: 1 addition & 1 deletion .Rproj.user/4C8EE3A7/pcs/workbench-pane.pper
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"TabSet1": 0,
"TabSet2": 1,
"TabSet2": 4,
"TabZoom": {}
}
2 changes: 1 addition & 1 deletion .Rproj.user/4C8EE3A7/sources/prop/53D28D73
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"source_window_id": "",
"Source": "Source",
"cursorPosition": "1101,0",
"scrollLine": "0",
"scrollLine": "299",
"docOutlineVisible": "1",
"rmdVisualCollapsedChunks": "",
"rmdVisualModeLocation": "33850:26770.400390625",
Expand Down
8 changes: 4 additions & 4 deletions .Rproj.user/4C8EE3A7/sources/prop/91139DE3
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"rmdVisualMode": "true",
"rmdVisualMode": "false",
"rmdVisualWrapConfigured": "true",
"tempName": "Untitled1",
"source_window_id": "",
"Source": "Source",
"cursorPosition": "884,0",
"scrollLine": "0",
"cursorPosition": "1354,15",
"scrollLine": "1352",
"docOutlineVisible": "1",
"rmdVisualCollapsedChunks": "",
"rmdVisualModeLocation": "33796:16858.400390625",
"rmdVisualModeLocation": "50667:25980",
"chunk_output_type": "console"
}
2 changes: 1 addition & 1 deletion .quarto/_freeze/optimization/execute-results/html.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .quarto/crossref/index.qmd/index.html.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"entries":[],"headings":["r-users-group","sign-up-for-list-serv","section","section-1","contact-info","r-lunch-labs"]}
{"headings":["r-users-group","sign-up-for-list-serv","section","section-1","contact-info","r-lunch-labs"],"entries":[]}
2 changes: 1 addition & 1 deletion .quarto/crossref/optimization.qmd/optimization.html.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"headings":["introduction","update-your-installation","profiling-benchmarking","parallel-computing","learn-lapplypurrrmap","motivating-example","a-somewhat-more-complex-example","additional-packages","the-parallel-package","the-doparallel-package","machine-learning---caret","big-data","object-size","each-of-these-data-types-occupies-a-different-amount-of-space-in-memory","cloud-computing","common-pitfalls","for-loops-and-vector-allocation","vectorized-functions"],"entries":[]}
{"entries":[],"headings":["introduction","update-your-installation","profiling-benchmarking","parallel-computing","learn-lapplypurrrmap","motivating-example","a-somewhat-more-complex-example","additional-packages","the-parallel-package","the-doparallel-package","machine-learning---caret","big-data","object-size","each-of-these-data-types-occupies-a-different-amount-of-space-in-memory","cloud-computing","common-pitfalls","for-loops-and-vector-allocation","vectorized-functions"]}
2 changes: 1 addition & 1 deletion .quarto/idx/getting-data.qmd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .quarto/idx/graphics-guide.qmd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .quarto/idx/index.qmd.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"title":"R Users Group","markdown":{"yaml":{"output":{"html_document":{"includes":{"in_header":"analytics.html"},"output_dir":"."}}},"headingText":"R Users Group","containsRefs":false,"markdown":"\n\n<link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Lato\" />\n\n<div id=\"header\">\n<img src=\"graphics-guide/www/images/urban-institute-logo.png\" width=\"350\">\n</div>\n\n\nThis website contains resources for using R at the Urban Institute for analysis, visualization, mapping, and more. Click on the links above to get started learning about R!\n\n*The Urban Institute R Users Group is committed to exposing researchers to the joy and power of R; developing beginner, intermediate, and advanced R skills; encouraging and supporting novel applications of R to public policy research; and building a diverse and mutually supportive community of R Users.*\n\n<!-- ![](images/heartyr.gif) -->\n\n<img src=\"images/heartyr.gif\" alt=\"gif of the R logo with hearts pourint out of it\" width=\"200\" height=\"200\"/>\n\ngif credits: [Allison Horst](https://twitter.com/allison_horst)\n\n## Sign up for List Serv!\n\nPlease fill out the following form to receive email updates about upcoming RUG events and trainings. We promise not to spam your inbox:\n\n###\n\n###\n\n<center>\n<iframe width=\"600\" height=\"330\" frameborder=\"0\" src=\"https://app.smartsheet.com/b/form/b47eba5ed1d74f8ab06f017311c339b9\"></iframe>\n</center>\n\n<center>\n\nFill out [this Smartsheet form](https://app.smartsheet.com/b/form/0e9d04ced47b489b8d14971ae6c2fb15) to unsubscribe from the RUG List Serv.\n\n</center>\n\n## Contact Info\n\nPlease don't hesitate to contact Aaron Williams ([email protected]) or Amy Rogin ([email protected]) with any thoughts or questions about R at the Urban Institute. \n\n## R Lunch Labs\n\nThe Urban Institute R Users Group hosts weekly lunch labs. R Lunch Labs are hands-on trainings for R users of all skill levels and soon-to-be R users. Each meeting begins with a 5-10 minute quick tip. Afterwards, attendees break into small groups and work on a range of topics including introduction to R, data management and plotting, mapping, and machine learning. Most users bring laptops, but there are a few extras for users without laptops. \n\nWe have currently paused R Lunch Labs, but they will be back soon! If you have an idea for a topic you want to present informally at a lunch lab, please let us know!\n\n"},"formats":{"html":{"execute":{"fig-width":7,"fig-height":5,"fig-format":"retina","fig-dpi":96,"df-print":"default","error":false,"eval":true,"cache":null,"freeze":false,"echo":true,"output":{"html_document":{"includes":{"in_header":"analytics.html"},"output_dir":"."}},"warning":true,"include":true,"keep-md":false,"keep-ipynb":false,"ipynb":null,"enabled":null,"daemon":null,"daemon-restart":false,"debug":false,"ipynb-filters":[],"engine":"markdown"},"render":{"keep-tex":false,"keep-source":false,"keep-hidden":false,"prefer-html":false,"output-divs":true,"output-ext":"html","fig-align":"default","fig-pos":null,"fig-env":null,"code-fold":"none","code-overflow":"scroll","code-link":false,"code-line-numbers":false,"code-tools":false,"tbl-colwidths":"auto","merge-includes":true,"latex-auto-mk":true,"latex-auto-install":true,"latex-clean":true,"latex-max-runs":10,"latex-makeindex":"makeindex","latex-makeindex-opts":[],"latex-tlmgr-opts":[],"latex-input-paths":[],"latex-output-dir":null,"link-external-icon":false,"link-external-newwindow":false,"self-contained-math":false,"format-resources":[]},"pandoc":{"standalone":true,"wrap":"none","default-image-extension":"png","to":"html","include-in-header":["analytics.html"],"css":["styles.css"],"toc":true,"output-file":"index.html"},"language":{},"metadata":{"lang":"en","fig-responsive":true,"quarto-version":"1.2.269"},"extensions":{"book":{"multiFile":true}}}}}
{"title":"R Users Group","markdown":{"yaml":{"output":{"html_document":{"includes":{"in_header":"analytics.html"},"output_dir":"."}}},"headingText":"R Users Group","containsRefs":false,"markdown":"\n\n<link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Lato\" />\n\n<div id=\"header\">\n<img src=\"graphics-guide/www/images/urban-institute-logo.png\" width=\"350\">\n</div>\n\n\nThis website contains resources for using R at the Urban Institute for analysis, visualization, mapping, and more. Click on the links above to get started learning about R!\n\n*The Urban Institute R Users Group is committed to exposing researchers to the joy and power of R; developing beginner, intermediate, and advanced R skills; encouraging and supporting novel applications of R to public policy research; and building a diverse and mutually supportive community of R Users.*\n\n<!-- ![](images/heartyr.gif) -->\n\n<img src=\"images/heartyr.gif\" alt=\"gif of the R logo with hearts pourint out of it\" width=\"200\" height=\"200\"/>\n\ngif credits: [Allison Horst](https://twitter.com/allison_horst)\n\n## Sign up for List Serv!\n\nPlease fill out the following form to receive email updates about upcoming RUG events and trainings. We promise not to spam your inbox:\n\n###\n\n###\n\n<center>\n<iframe width=\"600\" height=\"330\" frameborder=\"0\" src=\"https://app.smartsheet.com/b/form/b47eba5ed1d74f8ab06f017311c339b9\"></iframe>\n</center>\n\n<center>\n\nFill out [this Smartsheet form](https://app.smartsheet.com/b/form/0e9d04ced47b489b8d14971ae6c2fb15) to unsubscribe from the RUG List Serv.\n\n</center>\n\n## Contact Info\n\nPlease don't hesitate to contact Aaron Williams ([email protected]) or Amy Rogin ([email protected]) with any thoughts or questions about R at the Urban Institute. \n\n## R Lunch Labs\n\nThe Urban Institute R Users Group hosts weekly lunch labs. R Lunch Labs are hands-on trainings for R users of all skill levels and soon-to-be R users. Each meeting begins with a 5-10 minute quick tip. Afterwards, attendees break into small groups and work on a range of topics including introduction to R, data management and plotting, mapping, and machine learning. Most users bring laptops, but there are a few extras for users without laptops. \n\nWe have currently paused R Lunch Labs, but they will be back soon! If you have an idea for a topic you want to present informally at a lunch lab, please let us know!\n\n","srcMarkdownNoYaml":"\n\n<link rel=\"stylesheet\" href=\"//fonts.googleapis.com/css?family=Lato\" />\n\n<div id=\"header\">\n<img src=\"graphics-guide/www/images/urban-institute-logo.png\" width=\"350\">\n</div>\n\n## R Users Group\n\nThis website contains resources for using R at the Urban Institute for analysis, visualization, mapping, and more. Click on the links above to get started learning about R!\n\n*The Urban Institute R Users Group is committed to exposing researchers to the joy and power of R; developing beginner, intermediate, and advanced R skills; encouraging and supporting novel applications of R to public policy research; and building a diverse and mutually supportive community of R Users.*\n\n<!-- ![](images/heartyr.gif) -->\n\n<img src=\"images/heartyr.gif\" alt=\"gif of the R logo with hearts pourint out of it\" width=\"200\" height=\"200\"/>\n\ngif credits: [Allison Horst](https://twitter.com/allison_horst)\n\n## Sign up for List Serv!\n\nPlease fill out the following form to receive email updates about upcoming RUG events and trainings. We promise not to spam your inbox:\n\n###\n\n###\n\n<center>\n<iframe width=\"600\" height=\"330\" frameborder=\"0\" src=\"https://app.smartsheet.com/b/form/b47eba5ed1d74f8ab06f017311c339b9\"></iframe>\n</center>\n\n<center>\n\nFill out [this Smartsheet form](https://app.smartsheet.com/b/form/0e9d04ced47b489b8d14971ae6c2fb15) to unsubscribe from the RUG List Serv.\n\n</center>\n\n## Contact Info\n\nPlease don't hesitate to contact Aaron Williams ([email protected]) or Amy Rogin ([email protected]) with any thoughts or questions about R at the Urban Institute. \n\n## R Lunch Labs\n\nThe Urban Institute R Users Group hosts weekly lunch labs. R Lunch Labs are hands-on trainings for R users of all skill levels and soon-to-be R users. Each meeting begins with a 5-10 minute quick tip. Afterwards, attendees break into small groups and work on a range of topics including introduction to R, data management and plotting, mapping, and machine learning. Most users bring laptops, but there are a few extras for users without laptops. \n\nWe have currently paused R Lunch Labs, but they will be back soon! If you have an idea for a topic you want to present informally at a lunch lab, please let us know!\n\n"},"formats":{"html":{"identifier":{"display-name":"HTML","target-format":"html","base-format":"html"},"execute":{"fig-width":7,"fig-height":5,"fig-format":"retina","fig-dpi":96,"df-print":"default","error":false,"eval":true,"cache":null,"freeze":false,"echo":true,"output":{"html_document":{"includes":{"in_header":"analytics.html"},"output_dir":"."}},"warning":true,"include":true,"keep-md":false,"keep-ipynb":false,"ipynb":null,"enabled":null,"daemon":null,"daemon-restart":false,"debug":false,"ipynb-filters":[],"engine":"markdown"},"render":{"keep-tex":false,"keep-source":false,"keep-hidden":false,"prefer-html":false,"output-divs":true,"output-ext":"html","fig-align":"default","fig-pos":null,"fig-env":null,"code-fold":"none","code-overflow":"scroll","code-link":false,"code-line-numbers":false,"code-tools":false,"tbl-colwidths":"auto","merge-includes":true,"inline-includes":false,"preserve-yaml":false,"latex-auto-mk":true,"latex-auto-install":true,"latex-clean":true,"latex-max-runs":10,"latex-makeindex":"makeindex","latex-makeindex-opts":[],"latex-tlmgr-opts":[],"latex-input-paths":[],"latex-output-dir":null,"link-external-icon":false,"link-external-newwindow":false,"self-contained-math":false,"format-resources":[],"notebook-links":true,"format-links":true},"pandoc":{"standalone":true,"wrap":"none","default-image-extension":"png","to":"html","include-in-header":["analytics.html"],"css":["styles.css"],"toc":true,"output-file":"index.html"},"language":{"toc-title-document":"Table of contents","toc-title-website":"On this page","related-formats-title":"Other Formats","related-notebooks-title":"Notebooks","source-notebooks-prefix":"Source","section-title-abstract":"Abstract","section-title-appendices":"Appendices","section-title-footnotes":"Footnotes","section-title-references":"References","section-title-reuse":"Reuse","section-title-copyright":"Copyright","section-title-citation":"Citation","appendix-attribution-cite-as":"For attribution, please cite this work as:","appendix-attribution-bibtex":"BibTeX citation:","title-block-author-single":"Author","title-block-author-plural":"Authors","title-block-affiliation-single":"Affiliation","title-block-affiliation-plural":"Affiliations","title-block-published":"Published","title-block-modified":"Modified","callout-tip-title":"Tip","callout-note-title":"Note","callout-warning-title":"Warning","callout-important-title":"Important","callout-caution-title":"Caution","code-summary":"Code","code-tools-menu-caption":"Code","code-tools-show-all-code":"Show All Code","code-tools-hide-all-code":"Hide All Code","code-tools-view-source":"View Source","code-tools-source-code":"Source Code","code-line":"Line","code-lines":"Lines","copy-button-tooltip":"Copy to Clipboard","copy-button-tooltip-success":"Copied!","repo-action-links-edit":"Edit this page","repo-action-links-source":"View source","repo-action-links-issue":"Report an issue","back-to-top":"Back to top","search-no-results-text":"No results","search-matching-documents-text":"matching documents","search-copy-link-title":"Copy link to search","search-hide-matches-text":"Hide additional matches","search-more-match-text":"more match in this document","search-more-matches-text":"more matches in this document","search-clear-button-title":"Clear","search-detached-cancel-button-title":"Cancel","search-submit-button-title":"Submit","search-label":"Search","toggle-section":"Toggle section","toggle-sidebar":"Toggle sidebar navigation","toggle-dark-mode":"Toggle dark mode","toggle-reader-mode":"Toggle reader mode","toggle-navigation":"Toggle navigation","crossref-fig-title":"Figure","crossref-tbl-title":"Table","crossref-lst-title":"Listing","crossref-thm-title":"Theorem","crossref-lem-title":"Lemma","crossref-cor-title":"Corollary","crossref-prp-title":"Proposition","crossref-cnj-title":"Conjecture","crossref-def-title":"Definition","crossref-exm-title":"Example","crossref-exr-title":"Exercise","crossref-ch-prefix":"Chapter","crossref-apx-prefix":"Appendix","crossref-sec-prefix":"Section","crossref-eq-prefix":"Equation","crossref-lof-title":"List of Figures","crossref-lot-title":"List of Tables","crossref-lol-title":"List of Listings","environment-proof-title":"Proof","environment-remark-title":"Remark","environment-solution-title":"Solution","listing-page-order-by":"Order By","listing-page-order-by-default":"Default","listing-page-order-by-date-asc":"Oldest","listing-page-order-by-date-desc":"Newest","listing-page-order-by-number-desc":"High to Low","listing-page-order-by-number-asc":"Low to High","listing-page-field-date":"Date","listing-page-field-title":"Title","listing-page-field-description":"Description","listing-page-field-author":"Author","listing-page-field-filename":"File Name","listing-page-field-filemodified":"Modified","listing-page-field-subtitle":"Subtitle","listing-page-field-readingtime":"Reading Time","listing-page-field-categories":"Categories","listing-page-minutes-compact":"{0} min","listing-page-category-all":"All","listing-page-no-matches":"No matching items"},"metadata":{"lang":"en","fig-responsive":true,"quarto-version":"1.3.433"},"extensions":{"book":{"multiFile":true}}}},"projectFormats":["html"]}
2 changes: 1 addition & 1 deletion .quarto/idx/intro-to-r.qmd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .quarto/idx/mapping.qmd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .quarto/idx/optimization.qmd.json

Large diffs are not rendered by default.

Loading