Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 471 Bytes

046-ref-chunk.md

File metadata and controls

40 lines (28 loc) · 471 Bytes

Code chunks can be referenced via <<label>>. First, we define chunk-a:

1 + 1

Then use it in chunk-b (the reference needs to be on its own line):

f = function() {
    (1 + 1)^3
}
f()
## [1] 8

If the reference is not found, <<>> will not be resolved:

g = function() {
  # there is no chunk-z
  <<chunk-z>>
}

Or you can disable the reference via ref.chunk = FALSE:

# a literal string
h = "
<<chunk-a>>
"