Learn R Programming

rapport (version 0.3)

grab.chunks: Inline Chunk Contents

Description

Returns inline code chunks with or without tags that wrap them.

Usage

grab.chunks(x, tag.open = get.tags("inline.open"),
    tag.close = get.tags("inline.close"), include = FALSE,
    ...)

Arguments

x
a character vector
tag.open
a character value with opening tag regular expression
tag.close
a character value with closing tag regular expression
include
a logical value indicating whether chunks should be returned (defaults to FALSE)
...
additional arguments for gregexpr function

Value

  • a character vector with code chunks

Details

Default parameters are read from options:

  • 'inline.open',
  • 'inline.close'.

Examples

Run this code
s <- c("As you know, pi equals <%pi%>",  "2 raised to the power of 3 is <%2^3%>")
grab.chunks(s, "<%", "%>", FALSE)
## [1] "pi"  "2^3"
grab.chunks(s, "<%", "%>", FALSE)
## [1] "<%pi%>"  "<%2^3%>"

Run the code above in your browser using DataLab