A Quarto document has two R chunks. The first chunk creates an object called x. Can the second chunk use x, without recreating it?
- Correct: chunks in the same language run in one shared session, so objects persist across chunks in the order they appear.
- Wrong: caching affects whether a chunk’s computation is rerun on subsequent renders; it isn’t required for objects to be shared within a single render.
- Wrong: R chunks are not isolated from one another.
- Wrong: chunk labels identify chunks for referencing and error messages; they don’t control whether objects are shared.
You copy-paste an existing chunk to use as a starting point for a new one, but forget to change its label. What happens when you render the document?
- Correct: chunk labels must be unique within a document; a duplicate causes rendering to fail with an error.
- Wrong: Quarto does not silently rename duplicate labels.
- Wrong: chunk labels must be unique, and duplicates cause a rendering error.
- Wrong: this is not how Quarto handles duplicate labels; rendering fails outright.
You want a chunk’s code to run, but neither the code nor its output should appear anywhere in the rendered document (for example, a setup chunk loading packages). Which option should you use?
- Wrong:
eval: FALSEprevents the chunk from running at all, so packages would not actually be loaded. - Wrong:
error: FALSEcontrols whether rendering stops on an error; it does not hide code or output. - Wrong:
echo: FALSEhides only the code; the result would still appear. - Correct:
include: FALSEruns the chunk but hides both the code and any output.
How does Quarto expect chunk options to be written inside an R chunk?
- Wrong: chunk options are not set through R function calls.
- Wrong: this is the older R Markdown syntax; Quarto uses a different convention.
- Correct: Quarto chunk options are written as
#|commented lines directly below the chunk header. - Wrong: chunk options are written inline in the chunk itself, not in a separate file.