Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R Markdown displaying just displaying the result

I have been exploring with R Markdown and came across this question. All the reproducible example reports I found online such as this http://jeromyanglim.blogspot.ca/2012/05/example-reproducile-report-using-r.html has the code followed by the result.

I want to have just the result therefore hiding the code from the audience. For example, I would just like to display the end result of ggplot2 or googlevis without showing the long lines of loading data and coding.

Is there a way to do so?

like image 335
user1426485 Avatar asked Jun 07 '12 14:06

user1426485


People also ask

How do I show output in R markdown?

If you prefer to use the console by default for all your R Markdown documents (restoring the behavior in previous versions of RStudio), you can make Chunk Output in Console the default: Tools -> Options -> R Markdown -> Show output inline for all R Markdown documents .

How do I display output but not code in R?

include = FALSE prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks. echo = FALSE prevents code, but not the results from appearing in the finished file.

How do I get rid of output in R markdown?

You use results="hide" to hide the results/output (but here the code would still be displayed). You use include=FALSE to have the chunk evaluated, but neither the code nor its output displayed.

What is results =' Asis in R?

The solution to this problem is the chunk option results = 'asis' . This option tells knitr not to wrap your text output in verbatim code blocks, but treat it “as is.” This can be particularly useful when you want to generate content dynamically from R code.


1 Answers

Just add echo = FALSE to the code chunk options.

like image 117
Charlotte Wickham Avatar answered Oct 24 '22 06:10

Charlotte Wickham