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() {
  (
    <<chunk-a>>
  )^3
}
f()

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>>
"


Try the parsermd package in your browser

Any scripts or data that you put into this service are public.

parsermd documentation built on Aug. 21, 2025, 5:27 p.m.