- Mastering RStudio:Develop,Communicate,and Collaborate with R
- Julian Hillebrand Maximilian H. Nierhoff
- 1012字
- 2021-08-20 10:42:30
The R Markdown interface
After our first steps with R Markdown and our sample report, it is time to take a closer look at the R Markdown interface within the RStudio IDE.
Inspecting the R Markdowns panes
In the following screenshot, you can easily see that three panes play a role in the creation process of R Markdown documents:

We already know the Files pane, where the code and text of the report can be created. As recommended, the output of the .Rmd
file is shown in the Viewer pane. Next to the console pane is the R Markdown console, where you inspect the processing and creation of the .Rmd
file. If there are any code errors in your R Markdown file, the execution will be stopped and two new buttons will appear in the right corner.
While the Output window shows the normal processing until reaching the first error, the Issues window shows only the respective errors and the associated line, where the error seems to be.
Explaining the R Markdown File pane settings
In the File pane, various settings can be made. The following sections explain the details in the screenshot.

File tab arrows
At the top left corner, you will see two arrows. While a click on the right-facing arrow lets you go back to the previous source location, the left-facing arrow lets you go forward to the next source location.
Saving current document
On the right-hand side, there is a button to save the R Markdown document. When you make changes to your .Rmd
file in the File pane, hitting the Save button will not affect the output. To apply all the changes, you need to knit the file again. Then your output file will finally reflect the changes in your .Rmd
file.
Spell check
Next you can check the spelling of your text with a click on the icon. If there are no spelling errors, a small popup will appear; it will show that the spell check is complete. If there are any errors, another popup window will turn up and show you every word that seems to be wrong. When you are writing really long reports, the spelling check is a very handy tool.

Find/replace
Next, we see a magnifier icon called find/replace. This great tool was already described in Chapter 1, The RStudio IDE – an Overview and it helps you find and replace text and code on the fly.
Question mark
A click on the question mark icon, ?, will give you two more references to select:
- Using R Markdown: This will open a new page in your browser heading to the R Markdown reference page of RStudio (http://rmarkdown.rstudio.com/)
- Markdown Quick Reference: A click on this will open a new view in the help pane of RStudio, presenting a brief overview of the most important Markdown formatting options.
Knit HTML
As we already know, this button starts the knitting process of our R Markdown file and outputs an HTML file. A click on the down-facing arrowhead gives you the option to choose from among HTML, PDF, or Word as the output format.
Gear icon
The gear icon not only lets you edit the output format again, but also dives a lot deeper with several settings related to the chosen format.
Output Format: HTML
HTML is the standard and recommended output format. There are three areas in which settings can be made as you can see in the following screenshot:

Following is a description of the various tabs displayed in the preceding screenshot:
- In the General tab, you can adjust settings such as which syntax highlighting you prefer, whether you want to apply a custom CSS file to your reports, and more.
- The Figures tab lets you set a default height and width in inches for all the generated plots. Further, you can check whether you want to render your figures with captions.
- The Advanced tab gives you three more sophisticated options to check. For example, using smart punctuation will automatically produce a typographically correct output.
Output Format – PDF
PDF as an output format also offers three setting areas:

Following is a description of the various tabs displayed in the preceding screenshot:
- In the General tab, you can adjust the settings to include a table of contents, select a syntax highlighting, and more
- The Figures tab for the PDF output shows the same settings as the HTML output settings, but you can also check whether the figures should be cropped
- In the Advanced tab, you can select a LaTeX engine and choose whether you want to keep the Tex source file
Output Format – Word
If you like, you can also choose the output of a knitted document to be a Word file. The Word options window offers two setting areas. They are shown in the following screenshot:

Following is a description of the various tabs displayed in the preceding screenshot:
- The General tab only gives you the option to select a syntax highlighting
- The Figures tab offers the same settings as the HTML settings
Run and re-run icons
The run and re-run icons, already known from normal .R
files, allows you to run the code of a selected line, run the corresponding selection, or re-run the previous code region.
Chunks
The Chunks button opens a drop-down menu from where you can choose several options:

You can insert a plain R code chunk or jump between the existing chunks in your file. Moreover, you can run the previous, current, and next chunk, or you can run them all at once. The output of the chunks will be displayed in the normal console pane.
Jump to menu
The jump to menu also works for faster navigation through your code chunks. When you label each code chunk, it gets even easier to jump to the right chunk.

Viewer pane options
The following option is also available when you open your R Markdown output in an extra window:

A click on the Publish button will make it possible to directly publish your R Markdown file on http://rpubs.com/.
- Learning Cython Programming(Second Edition)
- Redis Applied Design Patterns
- C/C++算法從菜鳥到達(dá)人
- TestNG Beginner's Guide
- Python程序設(shè)計
- Scala Reactive Programming
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript
- 會當(dāng)凌絕頂:Java開發(fā)修行實錄
- Software-Defined Networking with OpenFlow(Second Edition)
- 計算機(jī)系統(tǒng)解密:從理解計算機(jī)到編寫高效代碼
- 青少年P(guān)ython趣味編程
- 虛擬現(xiàn)實:引領(lǐng)未來的人機(jī)交互革命
- Laravel 5.x Cookbook
- 計算機(jī)教學(xué)研究與實踐:2017學(xué)術(shù)年會論文集
- 數(shù)據(jù)科學(xué)之編程技術(shù):使用R進(jìn)行數(shù)據(jù)清理、分析與可視化