当前位置:网站首页>If you ask me about R code debugging, I will tell you head, STR, help

If you ask me about R code debugging, I will tell you head, STR, help

2022-07-07 04:50:00 Mrrunsen

RMardkown Your code can be more finely controlled when rendering , Such as whether the code is running 、 Whether or not shown 、 How to display 、 Whether the text is output 、 How to output 、 Whether the picture shows 、 How to display and so on .

Detailed information can be referred to Knitr Of Chunk options:https://yihui.org/knitr/options/. Here we mainly show the common format control based on personal experience .

I Code

eval

Whether to run code block , Some code blocks are not running , Just for display .

RMarkdown The code option for is to accept R Variable , Therefore, you can control whether a code block is executed according to specific conditions .

Below RMarkdown On behalf of isShow Is the result greater than 0 To decide whether to execute the second code block .

```{r,include = FASLE}

isShow <- rnorm(1) > 0

```

```{r, eval = isShow}

{eval some code}

```

echo

Whether to show the code block in the result , The code shown below indicates that it is not in the result file ( Such as html file ) Display code in , But it will show the results of the code : Text or pictures, etc .

```{r, echo = FALSE}{eval some code}```

tidy

Whether to format when displaying code , If TRUE, Then you can use formatR format R Code : transfer

原网站

版权声明
本文为[Mrrunsen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130747461181.html