Code Cell Options

Supported Cell Options in {webr-r} Blocks

Published

January 30, 2024

Modified

April 10, 2024

This article provides an in-depth overview of cell options supported in {webr-r} code blocks. These options play a crucial role in influencing the execution and output of executable code blocks. It’s important to note that these cell options are specified within comments at the top of a code block by using a hashpipe #| option: value.

Here’s an example of how you can use these options:

```{webr-r}
#| results: 'asis'
#| fig-width: 5

# R code here
```

In this example, the cell options results is set to 'asis', and fig-width is set to 5 inches.

These options can be customized to tailor the behavior of the code block based on your specific requirements. Understanding and using these options effectively can enhance the overall control and presentation of your code outputs.

Important

The {quarto-webr} extension does not support all of the cell options from Quarto or Knitr. Please consult the tables below for details on what is available.

quarto-webr

Note

Options listed here are unique to the {quarto-webr} extension and do not have a Quarto equivalent.

Run Options

Option Default Value Description
context interactive Describe how the cell should operate on the page through either interactive (Runnable code editor), output (Output only of executed at runtime), or setup (execute code without seeing output at runtime).
autorun false Allow interactive cells to be run during document initialization without a user pressing run code.
Note

For details regarding run options, please see Hiding and Executing Code.

Monaco Editor Options

Option Default Value Description
read-only false Prevent code in interactive cells from being modified by disallowing code input.
editor-max-height 0 Set a threshold to prevent infinite growth of the editor window.
editor-quick-suggestions false Show a list of autocomplete variables and/or functions based on what was typed.

Attributes

Option Default Value Description
label '' Unique label for code cell. Useful for debugging.
classes '' Classes to apply to cell container

Cell Output

Option Default Value Description
results markup Controls how to display the text results through either: markup (Mark up text output with appropriate environments), asis (Write text output as-is, raw text results directly into the output document), or hide (Hide text output).
output true Controls inclusion of results: true (all results), false (no results), or 'asis' (output as-is, raw text results directly into the output document).
warning true Preserve standard error output (warning(), message(), or stop()) in the output.
message true See prior entry.
Important

At the present time, we cannot differentiate between the type of condition being sent to standard error. Thus, if either warning or message is set to false, the output for both will be surpressed.

Figures

Option Default Value Description
fig-cap "" Figure caption that should appear under the canvas
dpi 72 Dots per inch to use in calculating pixel values for fig-height and fig-width, e.g. dpi * inches = pixels.
fig-width 7 Width of the plot (in inches)
fig-height 5 Height of the plot (in inches)
out-width 700px Width of the plot in the output document, which can be different from its physical fig-width such as "100%" or "250px".
out-height "" Height of the plot in the output document, similar to out-width.