See if chunk options like tidy, prompt and echo, etc work as
expected.
A normal
chunk
Do not
evaluate
No
evaluate or tidy
[{type:'Heading',depth:2,content:['Do not
tidy']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',tidy:'FALSE'}}]
Do not echo
[{type:'Heading',depth:2,content:['Do not
comment out
results']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',comment:'NA'}}]
Do not echo the 2nd expression
[{type:'Heading',depth:2,content:['Do not
evaluate, echo the 2nd
expression']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,',echo:'2'}}]
Only evaluate the first two expressions
[{type:'Heading',depth:2,content:['Add
prompts but no
tidy']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',tidy:'FALSE,',prompt:'TRUE'}}]
[{type:'Heading',depth:2,content:['Backslashes']},{type:'CodeBlock',text:"{\n#
can you deal with \\code{foo} or \\n, \\a?\ngsub('\\\\.', '\\\\\\\\', 'a.b.c') #
\\link{bar}\n}\ncat('a\\tb\\nc')",programmingLanguage:'{r}'}]
Other
formatR options
We can set formatR options globally:
options(formatR.blank = FALSE)
[{type:'Paragraph',content:['Or locally in
one chunk via ',{text:'tidy.opts',type:'CodeFragment'},'. Do not keep
comments:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,','tidy.opts':'list(comment'}}]
Move left braces to the next
line:
[{type:'Paragraph',content:['Indent by 2
spaces:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'demo,':'',eval:'FALSE,','tidy.opts':'list(indent'}}]
[{type:'Heading',depth:2,content:['Messages']},{type:'Paragraph',content:['Do
not include
messages:']},{type:'CodeBlock',text:"1+1\nmessage('helloooo!')",programmingLanguage:'{r',meta:{message:'FALSE'}}]
No warnings:
1:2+1:3
warning('no no no')
Select warnings using numeric
indices:
[{type:'Paragraph',content:['Invalid
indices will select
nothing:']},{type:'CodeBlock',text:'',programmingLanguage:'{r',meta:{'test-w,':'',warning:'3'}}]
The
results option
Do not show text results:
[{type:'Paragraph',content:['Flush all
results to the end of a
chunk:']},{type:'CodeBlock',text:'',programmingLanguage:'r',meta:{'demo,':'',results:'hold'}}]