问题
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
.
回答1:
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.
来源:https://stackoverflow.com/questions/23852000/change-prompt-character-in-knitr-for-jss