{"id":185,"date":"2013-05-25T10:02:02","date_gmt":"2013-05-25T14:02:02","guid":{"rendered":"http:\/\/www.clayford.net\/statistics\/?p=185"},"modified":"2024-11-17T11:16:02","modified_gmt":"2024-11-17T16:16:02","slug":"playing-with-r-markdown","status":"publish","type":"post","link":"https:\/\/www.clayford.net\/statistics\/playing-with-r-markdown\/","title":{"rendered":"Playing with R Markdown"},"content":{"rendered":"<p>I was playing with R Markdown in <a href=\"http:\/\/www.rstudio.com\/\">R Studio<\/a> and thought I&#8217;d share my results. I can&#8217;t believe how easy this is to use! In R Studio, just go File&#8230;New&#8230;R Markdown. This opens a new template with some helpful code ready to use. This is your Rmd file. It&#8217;s basically a script file, except not only can you submit R code from this file, you can also save the output and graphs into one fancy HTML page. This is so much easier than copying-and-pasting R code into a Word Press post and saving\/uploading\/linking to images created in R. For example, see <a href=\"http:\/\/www.clayford.net\/statistics\/machine-learning-for-hackers-chapter-2\/\">this post<\/a> I wrote a while back. It took a long time to make. <\/p>\n<p>Anyway, when you&#8217;re done, you click the Knit HTML button and your Rmd file is &#8220;knitted&#8221; into an HTML file. There&#8217;s a little bit of extra code you need to use to ensure proper formatting, but it&#8217;s super easy to use. Check out <a href=\"http:\/\/www.rstudio.com\/ide\/docs\/authoring\/using_markdown\">this page<\/a> to see how easy it is to use. You just surround chunks of your R code in some simple markup. <\/p>\n<p>So here&#8217;s what I did. First I worked through the Introductory session of <a href=\"http:\/\/www.amazon.com\/gp\/product\/0387954570\/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0387954570&#038;linkCode=as2&#038;tag=curiousanduseful\">Modern Applied Statistics with S<\/a> (MASS) by Venables and Ripley. Here is my <a href=\"http:\/\/www.clayford.net\/rmd\/mass_session.Rmd\">Rmd file<\/a> and <a href=\"http:\/\/www.clayford.net\/rmd\/mass_session.html\">final output<\/a>. Next I worked problem 4 from chapter 3 from <a href=\"http:\/\/www.amazon.com\/gp\/product\/052168689X\/ref=as_li_ss_tl?ie=UTF8&#038;camp=1789&#038;creative=390957&#038;creativeASIN=052168689X&#038;linkCode=as2&#038;tag=curiousanduseful\">Data Analysis Using Regression and Multilevel\/Hierarchical Models<\/a> by Gelman and Hill. Here&#8217;s the <a href=\"http:\/\/www.clayford.net\/rmd\/ch3p4.Rmd\">Rmd file<\/a> and <a href=\"http:\/\/www.clayford.net\/rmd\/ch3p4.html\">final output<\/a>. The final output links are the cool parts. Those are just HTML files with <em>embedded images<\/em>. I uploaded the Rmd files so you could see the marked-up R code. As you&#8217;ll see, there&#8217;s not much there. If you want your R code and associated output and graphs to be nicely formatted in HTML, just surround it with <\/p>\n<pre>```....```{r}<\/pre>\n<p> That&#8217;s it. You can also create headers using double-hashtags. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was playing with R Markdown in R Studio and thought I&#8217;d share my results. I can&#8217;t believe how easy&#8230; <a class=\"read-more\" href=\"https:\/\/www.clayford.net\/statistics\/playing-with-r-markdown\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-185","post","type-post","status-publish","format-standard","hentry","category-using-r"],"_links":{"self":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/comments?post=185"}],"version-history":[{"count":9,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/185\/revisions"}],"predecessor-version":[{"id":991,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/posts\/185\/revisions\/991"}],"wp:attachment":[{"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/media?parent=185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/categories?post=185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clayford.net\/statistics\/wp-json\/wp\/v2\/tags?post=185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}