有没有办法在R Markdown中像Stackoverflow等许多网站提供的“代码”格式中格式化代码。
我希望能够做到以下操作:
任何采用以下形式的模型
income ~ education + parental_income
...
我想在R markdown中模拟灰色文本,以便在最终编织文档时易于阅读。
有没有办法在R Markdown中像Stackoverflow等许多网站提供的“代码”格式中格式化代码。
我希望能够做到以下操作:
任何采用以下形式的模型
income ~ education + parental_income
...
我想在R markdown中模拟灰色文本,以便在最终编织文档时易于阅读。
可以使用反引号或缩进4个空格来生成等同于HTML <code>
</code>
标签块的效果。这里有一个Rmd文档,说明了这种行为。
---
title: "Sample Document"
author: "bigNumber"
date: "12/5/2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
here is some example code written in R Markdown. If we want to enter a code block we use the backtick, such as `inc ~ ed + occ`.
If we want a code block with multiple lines, indenting by 4 spaces also works
# first line of code
for(i in 1:100) {
# do something here
}
More text after the code block ends.
......和输出结果。不幸的是,我必须包含一张图片来展示它正确地呈现。
```
如果您不想将代码块缩进四个空格,可以使用
三个反引号放在单独的行上。
```
https://bookdown.org/yihui/rmarkdown/markdown-syntax.html#block-level-elements
\
income ~ education + parental_income``,应该与 Markdown 一样可以正常工作。 - Marius