dplyr function is displaying an output in R markdown

Viewed 257

I am knitting a R markdown and the output looks fine for now, except for the problem that for some reason the knitted html shows the dplyr::summarise output too. Even after turning off show messages and show warnings the output persists. Please note that when I run the code without knitting, the console doesn't show this output.

How can I suppress this from showing in the html?

library(tidyverse)

# Used in main code to summarize data 
## Summarize data 
DF_Summarize = DF%>% 
  group_by(Code) %>% 
  summarise(Count_2020 = n())

Output showing in html. Now these are the summarized values from the dataframe.

##  [1]   2 179   5  47   6  92  33   1   6   5   3  13   6  99   1   7   4   4 423
## [20]  53  11   7 110  35 101   6   2   7   3   2   1   2   1   7   4   1   3   6
## [39]   3   5   1   3   7  13   1  40   1   7   2   1   3  18   1   2  10   1   2
## [58]   1  40
1 Answers

You can just use echo = FALSE in the knitr chunk label.

i.e.

```{r summarize, echo = FALSE}
## Summarize data 
DF_Summarize = DF%>% 
  group_by(Code) %>% 
  summarise(Count_2020 = n())
```

If you have other chunk output that you do want to display, just break up the chunks and use echo = FALSE in the one you want to hide, and leave echo = TRUE for the others.

Related