In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the common settings of markdown in R language". In daily operation, I believe that many people have doubts about the common settings of markdown in R language. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what are the common settings of markdown in R language?" Next, please follow the editor to study!
R markdown common settin
Set 1.knitr::opts_chunk$set () globally, and add parameters to "()" to set the entire report.
two。 If you want the code to start with the greater-than prompt for R, use the option prompt=TRUE. If you want the result not to be protected by a pound sign, use the option comment=''.
3.tidy=TRUE can automatically rearrange code snippets to make the format more in line with the specification.
4.collapse=TRUE: the code and output of a code block is usually decomposed into multiple original text blocks. If a code block wants all the code and output to be written to the same original text block, add the option collapse=TRUE.
5. Childbirth 'file name .Rmd' can be called into the contents of another .Rmd file. If there are multiple .Rmd files that depend on the same code, you can use this method.
6.echo = TRUE also displays the code block + result.
Echo = FALSE does not display the code block, but displays the result. The code is prohibited from appearing in the final report, but the result is not prohibited. You can use this option when writing reports for people who don't want to see the R code.
7.eval=FALSE, # can make the code only show and not actually run. If such a code snippet has a name, it can be referenced in subsequent code snippets.
8.include=FALSE, which can run the code, but does not display the code and results in the final document. You can use this option if you don't want the setup code to appear in the report.
9.message = FALSE or warning = FALSE prevents messages or warnings from appearing in the final report.
10.results = 'hide' can hide text output; fig.show =' hide' can hide graphic output.
11.error = TRUE can still generate a final report when there is an error in the code. We rarely need to include error messages in the final version of the report, but error messages are useful when debugging .Rmd files. This option is useful if you use R for teaching activities and specifically want to include error messages. If you use the default setting error = FALSE, document generation will fail even if there is only one error.
twelve。 When the R Markdown article is long, contains a lot of R code, or takes a long time to run, repeatedly compiling the entire article results in unnecessary calculations because some code snippets have not been modified and the dependent data has not changed. Knitr provides caching, and the code snippet option cache=TRUE turns on caching for code snippets, allowing you to temporarily store the results of the last run (including text results and graphics) without having to run the code snippets repeatedly. When the contemporary snippet is modified, the cache is discarded and the snippet is rerun at compile time.
13. Caching is a feature that needs to be used with caution so that old results are not used incorrectly. When the following code snippet needs to use the previous code snippet result, if the previous result is changed, the later code snippet cannot use the cached result and must be recalculated. To do this, you should add the dependson= option, such as dependson=c ('codeA',' codeB'), in the following code snippet, where codeA and codeB are the tags of the previous code snippet, and the result will be used in this code snippet. You can also use the code snippet option autodep=TRUE,knitr to automatically determine the dependencies between the front and back code snippets, and each time the previous code snippet changes, the later code snippets are automatically recalculated without using the cached old results. It is recommended that you use caching only for code snippets that take a long time to calculate once, and be sure to add the dependson= option to code that depends on its results. Because the caching strategy becomes increasingly complex, you should use the knitr::clean_cache () command to clear all caches periodically.
14. If you prefer to use tables to display data, you can use the knitr::kable function
15. Use out.width to control the size of the output drawing and set it as a percentage of the line width. The default settings are out.width = "70%" and fig.align = "center". This setting graphic will neither take up too much space nor appear too crowded. If you want the fonts in all your drawings to be the same size, as long as you set out.width, you also need to adjust fig.width to the same ratio as the default out.width. For example, if the default fig.width is 6 fig.width and width is 0.7, then when you set out.width = "50%", you need to set the fig.width to 4.3 at the same time.
At this point, the study of "what are the common settings of markdown in R language" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.