Automated Document Generation Using RMarkdown · Email: [email protected] 12. Title:...
Transcript of Automated Document Generation Using RMarkdown · Email: [email protected] 12. Title:...
![Page 1: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/1.jpg)
Automated Document Generation Using RMarkdown
October 24, 2018Eric Budge, M.S.
Data Analyst, Insight Policy Research, Inc.
![Page 2: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/2.jpg)
What is RMarkdown?
• Variation of R designed to generate HTML, PDF, and Word documents
• Easy to incorporate code and figures
• Create highly specified templates
• Adaptable to loops
2
![Page 3: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/3.jpg)
Layout• Three types of environment
1. Preamble: set template, title, author, and formats
2. R Chunk: runs R codes and displays results in document
3. Text: body text, headers, bullets, and lists
3
![Page 4: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/4.jpg)
Inserting Data to the Text
4
Rmarkdown Code
Document Output
![Page 5: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/5.jpg)
Generating Multiple Documents
5
![Page 6: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/6.jpg)
Output
• One document for each of the states
• Every document contains the same language, figures, and formats
• All values are state specific and accurate
6
![Page 7: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/7.jpg)
Output
7
![Page 8: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/8.jpg)
Output
8
![Page 9: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/9.jpg)
Output
9
![Page 10: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/10.jpg)
Output
10
![Page 11: Automated Document Generation Using RMarkdown · Email: ebudge@insightpolicyresearch.com 12. Title: GASP Author: Eric Budge Created Date: 11/2/2018 6:50:05 PM ...](https://reader033.fdocuments.net/reader033/viewer/2022042312/5eda5f9cb3745412b5713c76/html5/thumbnails/11.jpg)
Resources
• RMarkdown Basics:
• https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf
• https://bookdown.org/yihui/rmarkdown/
• Templates:
• https://rmarkdown.rstudio.com/developer_document_templates
• http://jianghao.wang/post/2017-12-08-rmarkdown-templates/
• SNAP Data Used:
• U.S. Department of Agriculture, Food and Nutrition Service, Office of Policy Support, Characteristics of Supplemental Nutrition Assistance Program Households: Fiscal Year 2016, by Sarah Lauffer. Project Officer, Jenny Genser. Alexandria, VA, 2017. Appendix B, Tables B1 through B4. https://fns-prod.azureedge.net/sites/default/files/ops/Characteristics2016.pdf
• Download R and Rstudio:
• https://www.r-project.org/
• https://www.rstudio.com/
11