5 Tips to Use R Markdown for Analytics in Data Science
Introduction to R Markdown
It is an open source tool for creating a reproducible report in R. You can put all of your codes, results and whatever you have written in an eye-catching and comprehensive format. Like any other one, the report in it would show off the real value of your data work to others because you can export your work in PDFs, MS Word, a slideshow or an HTML doc, integrating them with a website.
Basically, this is a powerful tool for data analysis and science, collaborating inputs and communicating results to strategists. You would fall for it upon learning how easy it is to use R for data science for the reports through these shortcuts and tricks:
1. Shortcut Keys
You can many valuable minutes that you spend on creating reports with these time-saving shortcut keys:
- For inserting new codes on a Mac, use Command + option + I. If you’re using Linux or Windows, press these combination keys: Ctrl + Alt + I.
- Get an output at the top of your R Markdown script, also called a YAML header, pressing Command + Shift + K on Mac and Ctrl + Shift + K on Linux and Windows.
- Gear up for restarting your R session with a clean environment by pressing Command + Shift + F10 on Mac and Ctrl + Shift + F10 on Windows and Linux.
- Run the current code with the new codes using Command + Option + P on Mac and Ctrl + Alt + P on Linux and Windows.
- If you want just the current code would run, press Command + Option + C or Command + Shift + Enter on Mac and Ctrl + Alt + C or Ctrl + Shift + Enter on Linux and Windows.
- Get the next code run with Command + Option + N on Mac and Ctrl + Alt + N on Linux and Windows.
- If you want to run all codes, press Command + Option + R or Command + A + Enter on Mac and Ctrl + Alt + R or Ctrl + A + Enter on Linux and Windows.
2. Get a Quick Preview
It’s true that R Markdown supports PDF, HTML and MS Word formats for compiling your document. If you want to catch up with this fact, see the output upon rendering in a web browser. By default, it prefers HTML over PDFs or Presentation because of its capacity to render quicker than these.
So, it is always better to choose it over any other one if you really want to save your time. If PDF or Word format is what you need to have, you can switch to the preferable format in an out, making final touches.
3. Code Options in R Markdown
This excellent reporting tool offers most of controls, as how your code should be evaluated or presented. Even, you can create presentations and reports from scratch while embedding codes, plots, tables and images. If you don’t want to show up the codes to the audience, you can do.
Here are a few vital alternatives that can help you to create a desirable report:
- Hide the code and flash outputs, plots, warning and other messages using echo = FALSE.
- Show up code without evaluating it, using eval = FALSE.
- Hide plots using fig.show = “hide”.
- Set up & render code without showing all outputs using include = FALSE.
- Avoid printing messages while loading, which are generally generated by functions, using message = FALSE.
- Hide the printed output using results = “hide”.
- Prevent functions from showing up warning, using warning = FALSE.
4. Use Inline Code
This code enables you to integrate R code into an R Markdown doc so that you can include information about your data in the written summary. You can also add the code to get the result within the backticks (“). For preventing the code from rendering, use the aforementioned syntax, i.e. eval = FALSE.
5. TinyTex
If you want output as a high-quality report, which takes minimum megabytes, TinyTex is the best alternative. It consumes about 159 megabytes on installation. This is the most flexible tool to generate the report that includes scientific or mathematical symbols and notation.
For installing it, type install.packages (‘tinytex’) or tinytex::install_tinytex (). You can undo this action by entering uninstall.packages (‘tinytex’) or tinytex::uninstall_tinytex (). This installation can help you to output in a PDF in its specified format.
These are just a few shortcuts. There are a lot more to get most out of this remarkable reporting tool, support R in data science.
Post Comment
Your email address will not be published. Required fields are marked *