[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-detail-701086-en":59,"doc-seo-701086-105":98,"doc-similar-701086":161},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":5,"data":60},{"doc_id":61,"user_id":62,"nickname":63,"user_avatar":64,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":66,"doc_content":67,"file_id":68,"file_url":69,"file_type":70,"file_size":71,"view_count":72,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":34,"language":73,"language_code":74,"site_id":75,"html_lang":74,"table_of_contents":76,"faqs":77,"seo_title":78,"seo_description":66,"update_tm":79,"read_time":80,"preview_page_count":19,"preview_urls":81},701086,1099523882367,"Jordan Avery","https://ap-avatar.wpscdn.com/davatar_9964176cb1d06d4a9deccf72a44ae3dc","Getting Started with R Markdown - A Short Introduction","Getting Started with R Markdown introduces how to integrate plain text and R code into a single compiled document for scientific communication. It explains the difference between .R scripts and .qmd (Quarto) files, describes how to create and edit a new .qmd in RStudio, including code chunks and inline code, and shows how knitting compiles the entire document into formats such as HTML or PDF. It also recommends using both .R and .qmd during problem solving to work faster, stay organized, and archive the process.","Getting Started with R Markdown Tyler J. Loewenstein Ryan T. Moore∗ Wednesday 20th September, 2023 at 15:53  \nThis is a short introduction to using R Markdown on problem sets and labs. Before using this guide, read the Short Guide to R and RStudio available at [ryantmoore.com/teaching.html](ryantmoore.com/teaching.html).  \n1 Background  \nR Markdown is a useful format for integrating plain text information and code into one compiled document. It can be used to create reports, articles, slide presentations, and a variety of other formats for scientiﬁc communication. Quarto ( .qmd) ﬁles can be rendered or knitted to create documents in HTML, PDF, or Microsoft Word. For this class, we recommend a package called tinytex to create the PDF ﬁles that you will submit to Blackboard. Instructions for installing tinytex can be found via at [http://www.ryantmoore.org/](http://www.ryantmoore.org/)ﬁles/ht/httinytex.pdf.  \n.R ﬁles versus .qmd ﬁles  \nIt can be easy to confuse the two types of ﬁles used in RStudio. Both .R and .qmd ﬁles can be used to write and run code, but they will each play a diﬀerent role when performing data analysis.  \nA .R ﬁle will    \n• Accept only functions and scripts written in R  \n• Ignore anything that is commented out using the \\# symbol.  \n• Keep a record of your code as you work  \n• Allow you to run one or more lines of code at a time  \n∗ Department of Government, American University, Kerwin Hall 228, 4400 Massachusetts Avenue NW, Washington DC [20016-8130. tel:](20016-8130. tel:) 202.885.6470; fax: 202.885.2967; rtm (at) american (dot) edu;  \n[http://ryantmoore.org](http://ryantmoore.org).  \nA .qmd ﬁle will . . .  \n• Accept both code and regular text  \n• Evaluate R code written in gray chunks (more on this later)  \n• Allow you to format the document around your code  \n• Compile the entire document before outputting your work  \n2 Using R Markdown  \nNow that you know the diﬀerences between an .R and .qmd ﬁle, it is important to recognize how they can be integrated into your workﬂow. This section will illustrate how they can be integrated into your workﬂow, and even work together.  \nCreating an .qmd ﬁle  \nCreating an .qmd is similar to creating an .R ﬁle. To begin, open RStudio and select File > New File > Quarto Document.  \nRStudio will ask you to give the document a title and select the default output. If you have tinytex installed, you should select PDF. Otherwise, choose HTML. Once you have ﬁlledin these ﬁelds, select OK.  \nThe default .qmd includes some sample text to show new users the kinds of information that can be entered. To remove this, simply delete lines 12 to 31. After you’ve done that, your ﬁle should look like this:  \nAdding content to an .qmd ﬁle  \nYour new .qmd ﬁle will accept both code and regular text. Anything you want R to evaluate (i.e. your code) should be placed inside a code chunk. To make a new chunk, select a blank line and type out three backticks followed by curly brackets that contain the letter r. Skipa few lines and type three more backticks to close the chunk. You can also add a chunk by selecting Code > Insert Chunk. Any lines inside a code will appear gray.  \nText can be added to your document normally by typing anywhere outside of a code chunk. There are numerous ways to customize your .qmd using LATEX, a document preparation system commonly used in social science. To learn more, you can read the Getting Started with LATEX guide via the URL at the top of this guide. For now, you can add a section header by using the \\# symbol.  \nHere is an example of how to format the answer to a problem set using these techniques:  \nThere is another way to add code into an .qmd: inline code. This allows you to write sentences as you would normally, but also integrate the results of your code. This is done by putting your code inside of `r ` instead of a regular chunk. Here’s an example:  \nInstead of typing    \n• The sum of 12 and 45 is: 57 .  \nYou can type . . .  \n• The sum of 12 and 45 is :","cbCaiakm4bqAX1wI","https://ap.wps.com/l/cbCaiakm4bqAX1wI","pdf",840375,3,"English","en",105,"# Background\n# Using R Markdown\n## Creating an .qmd file\n## Adding content to an .qmd file\n## Compiling a .qmd file\n# Optimizing Your Workflow","[{\"question\":\"How does an .R file differ from a .qmd file in RStudio?\",\"answer\":\"An .R file accepts only R code and records your scripts as you work, while a .qmd file accepts both code and regular text, evaluates code in gray chunks, and compiles the full document before outputting results.\"},{\"question\":\"How do you create a new .qmd document in RStudio?\",\"answer\":\"Open RStudio and select File \\u003e New File \\u003e Quarto Document. Give the document a title and choose the default output (PDF if tinytex is installed, otherwise HTML), then confirm with OK.\"},{\"question\":\"What is knitting, and why can it fail?\",\"answer\":\"Knitting is the process of compiling the entire .qmd document into the selected output format via the Render button. If any line is incorrect or missing a character, RStudio produces an error and the document will not be knitted.\"}]","Getting Started with R Markdown - A Short Introduction | PDF",1794523303,18,[82,86,90,94],{"page_no":8,"url":83,"width":84,"height":85},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/4de1914d247feea647cd04087ddd7020.webp",983,1272,{"page_no":14,"url":87,"width":88,"height":89},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/223ce4c752cd349506162e81fefe2ee1.webp",982,1270,{"page_no":72,"url":91,"width":92,"height":93},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/bf6c0910b812e20122a0c4050ac2d38c.webp",981,1269,{"page_no":19,"url":95,"width":96,"height":97},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-12/81fe9609ca5f739447683ff94db7d875.webp",980,1268,{"code":4,"msg":99,"data":100},"ok",{"site_id":75,"language":74,"slug":101,"title":65,"keywords":102,"description":66,"schema_data":103,"social_meta":156,"head_meta":158,"extra_data":160,"updated_unix":79},"getting-started-with-r-markdown-a-short-introduction","",{"@graph":104,"@context":155},[105,118,138],{"@type":106,"itemListElement":107},"BreadcrumbList",[108,112,114,116],{"item":109,"name":110,"@type":111,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":113,"name":9,"@type":111,"position":14},"https://docshare.wps.com/document/",{"item":115,"name":30,"@type":111,"position":72},"https://docshare.wps.com/document/technology/",{"item":117,"name":65,"@type":111,"position":19},"https://docshare.wps.com/document/getting-started-with-r-markdown-a-short-introduction/701086/",{"url":117,"name":65,"@type":119,"image":120,"author":125,"headline":65,"publisher":127,"fileFormat":130,"inLanguage":74,"description":66,"dateModified":131,"datePublished":132,"encodingFormat":130,"isAccessibleForFree":133,"interactionStatistic":134},"DigitalDocument",{"url":121,"@type":122,"width":123,"height":124},"https://docshare.wps.com/thumbnails/getting-started-with-r-markdown-a-short-introduction/701086.png","ImageObject",300,407,{"name":63,"@type":126},"Person",{"url":109,"name":128,"@type":129},"DocShare","Organization","application/pdf","2026-11-16","2026-11-12",true,{"@type":135,"interactionType":136,"userInteractionCount":72},"InteractionCounter",{"@type":137},"ViewAction",{"@type":139,"mainEntity":140},"FAQPage",[141,147,151],{"name":142,"@type":143,"acceptedAnswer":144},"How does an .R file differ from a .qmd file in RStudio?","Question",{"text":145,"@type":146},"An .R file accepts only R code and records your scripts as you work, while a .qmd file accepts both code and regular text, evaluates code in gray chunks, and compiles the full document before outputting results.","Answer",{"name":148,"@type":143,"acceptedAnswer":149},"How do you create a new .qmd document in RStudio?",{"text":150,"@type":146},"Open RStudio and select File > New File > Quarto Document. Give the document a title and choose the default output (PDF if tinytex is installed, otherwise HTML), then confirm with OK.",{"name":152,"@type":143,"acceptedAnswer":153},"What is knitting, and why can it fail?",{"text":154,"@type":146},"Knitting is the process of compiling the entire .qmd document into the selected output format via the Render button. If any line is incorrect or missing a character, RStudio produces an error and the document will not be knitted.","https://schema.org",{"og:url":117,"og:type":157,"og:title":65,"og:site_name":128,"og:description":66},"article",{"robots":159,"canonical":117},"index,follow",{"doc_id":61,"site_id":75},{"list":162,"token":102},[163,169,175,181,187,193,199,206,213,219],{"doc_id":164,"doc_title":165,"file_type":70,"home_preview_img_url":166,"slug":167,"view_count":52,"category_name":30,"create_tm":168},657500,"CS&SS 569 Visualizing Data and Models - Lab 2 - Intro to LATEX with R Markdown and Overleaf","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229975094700/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=4bUsxOjrk7cs81YUvtW%2FGLlpbfw%3D","csss-569-visualizing-data-and-models-lab-2-intro-to-latex-with-r-markdown-and-overleaf",1792981475,{"doc_id":170,"doc_title":171,"file_type":70,"home_preview_img_url":172,"slug":173,"view_count":19,"category_name":30,"create_tm":174},685848,"WRITING YOUR ESSAY USING R MARKDOWN - SOMETHING FOR EVERYONE - Introduction","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000227888/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=EMOuD7B0IFROjnvuBITBDEd7pl0%3D","writing-your-essay-using-r-markdown-something-for-everyone-introduction",1794019545,{"doc_id":176,"doc_title":177,"file_type":70,"home_preview_img_url":178,"slug":179,"view_count":72,"category_name":30,"create_tm":180},703189,"R Markdown Tutorial - Basic Knowledge - Codes and Tables","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230012260744/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=yupDKjC5CZfsCU84ymVf41uhEaA%3D","r-markdown-tutorial-basic-knowledge-codes-and-tables",1794562577,{"doc_id":182,"doc_title":183,"file_type":70,"home_preview_img_url":184,"slug":185,"view_count":72,"category_name":30,"create_tm":186},685847,"R Markdown - An Introduction","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999698626/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=7RuXEvEmXZNjaW4024AZL4FSZy0%3D","r-markdown-an-introduction",1794019543,{"doc_id":188,"doc_title":189,"file_type":70,"home_preview_img_url":190,"slug":191,"view_count":72,"category_name":30,"create_tm":192},701084,"R Markdown: The Definitive Guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230011578502/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=qSL9sWuVG6aR9OnZExsX%2F2e6Hiw%3D","r-markdown-the-definitive-guide",1794523292,{"doc_id":194,"doc_title":195,"file_type":70,"home_preview_img_url":196,"slug":197,"view_count":24,"category_name":30,"create_tm":198},685841,"Markdown Syntax Guide - Quick Reference","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000227664/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=ZgMI6fCoLJ4Tn3Bj9bzDUsOQRE0%3D","markdown-syntax-guide-quick-reference",1794019531,{"doc_id":200,"doc_title":201,"file_type":70,"home_preview_img_url":202,"slug":203,"view_count":204,"category_name":30,"create_tm":205},348237,"rmarkdown Cheatsheet 2.0","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911603589/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=Rx72lriZtqwgbyvh9lZVJbD4jnQ%3D","rmarkdown-cheatsheet-20",15,1790071904,{"doc_id":207,"doc_title":208,"file_type":70,"home_preview_img_url":209,"slug":210,"view_count":211,"category_name":30,"create_tm":212},348231,"Markdown Cheatsheet","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229911603533/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=nyyV8NHpLJ7GPP%2FnUyre60FFmX4%3D","markdown-cheatsheet",14,1790071893,{"doc_id":214,"doc_title":215,"file_type":70,"home_preview_img_url":216,"slug":217,"view_count":72,"category_name":30,"create_tm":218},698002,"Generate Mind Maps - Convert Documents with mindr - Version 1.4.1","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010155841/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=%2BQWnUGih46X9QAf7XyeuAqm8qXM%3D","generate-mind-maps-convert-documents-with-mindr-version-141",1794446940,{"doc_id":220,"doc_title":221,"file_type":70,"home_preview_img_url":222,"slug":223,"view_count":19,"category_name":30,"create_tm":224},697998,"Markdown cheat sheet - guide","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010155625/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111279&Signature=weCg4DLIYpg2i00RlGaIOayeNUU%3D","markdown-cheat-sheet-guide",1794446932]