-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcontrolling_knitr.Rmd
66 lines (48 loc) · 1.24 KB
/
controlling_knitr.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Controlling knitr output
========================================================
You can control what is output from code chunks by changing knitr options.
options are described [here](http://yihui.name/knitr/options) in detail.
Below some of the options I most use are shown.
Code evaluation
-------------------------
`eval=FALSE` will turn the code evaluation off. The code still will be shown.
with `eval=TRUE`
```{r}
summary(cars)
```
with `eval=FALSE`
```{r,eval=FALSE}
summary(cars)
```
Supressing warnings
-------------------------
You can supress warnings in the code output by setting `warning=FALSE`
`warning=TRUE`
```{r}
cor(c(1,1,1),c(1,1,1))
```
`warning=FALSE`
```{r,warning=FALSE}
cor(c(1,1,1),c(1,1,1))
```
Supressing messages
-------------------------
You can suppress messages from the code by setting `message=FALSE`
`message=TRUE`
```{r}
library(GenomicRanges)
```
`message=FALSE` for the R chunk.
```{r,message=FALSE}
library(GenomicRanges)
```
Evaluate code but hide figures
-------------------------
```{r fig.width=7, fig.height=6}
plot(cars)
```
You can also execute code but hide the figures with `fig.show='hide'` option for the R chunk.
```{r fig.width=7, fig.height=6,fig.show='hide'}
plot(cars)
summary(cars)
```