Change prompt character in knitr for JSS

杀马特。学长 韩版系。学妹 提交于 2019-12-22 09:23:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!