Giter Site home page Giter Site logo

Comments (2)

jeromyanglim avatar jeromyanglim commented on August 11, 2024

Where to go to learn about knitr R code chunk options?

Give code chunks short informative names

Naming code chunks is optional but useful:

  • increase code readability
  • labels show up in R Studio navigation tools
  • labels are used to create figure names and cached object names

The distinction between global and local R code chunk options?

Global options

LaTeX

 \Sexpr{ opts_chunk$set(opt = value) }

R Markdown

 `r opts_chunk$set(opt = value)`

I use global options particularly for:

  • caching
  • hiding console input for certain documents

Local options appear in code chunks.

The different delimiters for R Markdown and knitr LaTeX?

R Latex

<<insert_options_here>>=

@

R Markdown

```{r insert_options_here}

```
  • Code options start with an optional name and a set of one or more options (also optional).
  • All names and options are separated by a comma
  • Each option is of the form option=value where option is a specified keyword, and value is an R expression, but typically a character, number, or TRUE/FALSE value.

How to hide console input?

echo = FALSE

How to hide unwanted output such as messages and errors?

warning=FALSE, error=FALSE, message=FALSE

How to hide console output?

results='hide'

How to output text that gets incorporated into output?

In LaTeX i often use cat to write raw tex output to create custom tables.
Similarly if you are using xtable to produce a HTML table, it is necessary for the output to be written literally to the document.

results='asis'

How to cache code chunks?

Often applied globally as

opts_chunk$set(cache=TRUE)

How to disable code tidying?

I often take care to arrange my code in a readable way and code tidying can reduce the readability.

tidy=FALSE

from rmarkdown-rmeetup-2012.

piccolbo avatar piccolbo commented on August 11, 2024

error=FALSE does something different, stops executions in case of error. I am still looking for a way to suppress errors while continuing execution.

from rmarkdown-rmeetup-2012.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.