Testing text output

See if chunk options like tidy, prompt and echo, etc work as expected.

A normal chunk

for (i in 1:10) {
# nothing before 10
# two blank lines below


Do not evaluate

Add prompts

No evaluate or tidy

Do not tidy

Do not echo

Do not comment out results

Do not echo the 2nd expression

Do not evaluate, echo the 2nd expression

Only evaluate the first two expressions

Add prompts but no tidy

Prompts, no evaluate or tidy

Change prompts

options(prompt='R> ', continue='+  ')


# can you deal with \code{foo} or \n, \a?
gsub('\\.', '\\\\', 'a.b.c') # \link{bar}

Other formatR options

We can set formatR options globally:

options(formatR.blank = FALSE)

Or locally in one chunk via tidy.opts. Do not keep comments:

Move left braces to the next line:

Indent by 2 spaces:

See http://yihui.org/formatR for details.

Empty chunks


Do not include messages:


No warnings:

warning('no no no')

Select warnings using numeric indices:

Invalid indices will select nothing:

The results option

Do not show text results:

Flush all results to the end of a chunk:

Output as is:

cat('_Markdown_,', 'oh yeah, **Markdown**')

Try the parsermd package in your browser

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

parsermd documentation built on May 20, 2021, 5:08 p.m.