Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change prompt character in knitr for JSS

Tags:

r

knitr

The Journal of Statistical Software style guide prescripes use of R> as prompt character. In Sweave this can be obtained through:

options(prompt = "R> ", continue = "+  ", width = 70, useFancyQuotes = FALSE)

Is it possible to set the prompt character in knitr as well? It seems like the prompt argument in chunks$set only allows for TRUE/FALSE.

like image 985
Jeroen Ooms Avatar asked Nov 23 '25 10:11

Jeroen Ooms


1 Answers

Use this kind of setup in the .Rnw file:

<<setup, include=FALSE, cache=FALSE>>=
library(knitr)
# set global chunk options
opts_chunk$set(prompt=TRUE)
options(replace.assign=TRUE, width=90, prompt="R> ")
@

Notice I say prompt=TRUE in the opts_chunk$set() and then specify what type of prompt in the options in the next line.

like image 89
Tyler Rinker Avatar answered Nov 25 '25 04:11

Tyler Rinker