Testing text output

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

A normal chunk

1+1
for (i in 1:10) {
# nothing before 10
if(i>=10)print(i)
}
# two blank lines below


dnorm(0)

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='+  ')

Backslashes

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

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


Messages

Do not include messages:

1+1
message('helloooo!')

No warnings:

1:2+1:3
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.