top of page

Document Preparation... in R?

  • Writer: CANA
    CANA
  • Sep 2, 2016
  • 2 min read

Updated: Sep 13, 2022


R-Markdown

R Markdown

I've gone a little bit off the 'deep end' when it comes to programming in R recently. I was turned on to Markdown a few months ago by a friend, but haven't really had time to play with it. Until now. The builders of Markdown at RStudio have a technical explanation of Markdown; but to me, it is: A tool that brings word processing functions to a level playing field with the analysis and graphics already resident in R.

Ok, sounds cool - why would anyone want that?

When I start an analysis project, I'm a madman (sorry, colleagues). I write code like a fiend and have datasets with names like: TF, TFNZ, TFD, TFD2, TFDD, TotalMassRetain, SiberianKhatru, and so on. At some point, the mania of the beginning of the project settles down, and there are three things I have to do.

Tasks: 1. Write Stable, usable code. Note: 'Usable' means 'Usable by someone other than me' 2. Write a report 3. Produce professional graphics, export, save, reformat, import, resize, etc.

R-Markdown Old vs New

This is how using Markdown compares with my previous production method. Three disparate tasks are now combined into one, consolidated task.

Markdown puts the code in the document. It's hard to think of a better, more stable way to save code. Chunks of code are inside the document (and can be easily cross-ported using the <- To Console function of the History window in RStudio). This is especially useful when importing graphics, because they are automatically created and rendered in the destination format. Markdown can render (or knit) to Word, HTML, or LaTeX. And, if the data changes, the report changes as well.

A very quick drive The RStudio example uses the mtcars dataset that comes standard in R::Base. Here, I'm going to play with the 'Old Faithful' dataset, which can be accessed by the command data ("faithful"). We can compute a summary of the data in the following chunk of code:

{R tableEX, echo = FALSE} faithful %>% summary() %>% kable()

eruption waiting table

We can also make nice looking graphs using ggplot2:

eruptions wait time plotted

Eruptions and Waiting Time for Old Faithful

We can even do linear regression inside Markdown:

Two final thoughts 1. If wanted to repeat analysis with different data, I would only have to change one line of code. 2. This document was written in R Markdown.

Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

 
 
 

5 Comments


Lotus365 login opens the door to an exciting betting platform filled with endless opportunities. With Lotus 365 login, you can explore thrilling promotions and a user-friendly experience like no other. The Lotus365 is quick and hassle-free, ensuring you never miss a moment of the action. Step in today and enjoy the ultimate betting experience!


Visit on- https://officiallotus365.com/login



Like

Step into the world of endless excitement with Skyexch! With top-notch features and live updates, Skyexch ensures a premium betting experience like no other. Create your Skyexch account today to access exclusive offers and start your winning journey. Don’t wait—join Skyexch now and elevate your game


For more details visit on- https://skyexch-com.in/



Like

Experience the thrill of IPL like never before with FairPlay24!  Don’t miss out—create your FairPlay24 login today and explore exciting promotions tailored for you.From unbeatable odds to live betting action, Fairplay24.in offers everything you need to maximize your winnings. Bet smarter, win bigger, only on FairPlay24!


For more details visit on- https://fairplay24.bet/


Like


IKQQ WEHH
IKQQ WEHH
Nov 15, 2024

谷歌seo推广 游戏出海seo,引流,快排,蜘蛛池租售;

Fortune Tiger Fortune Tiger;

Fortune Tiger Fortune Tiger;

Fortune Tiger Fortune Tiger;

Fortune Tiger Fortune Tiger;

Fortune Tiger Slots Fortune Tiger Slots;

Like
bottom of page