学习笔记,仅供参考,有错必纠
参考自:官方文档rmarkdown;R Markdown中配置python
R Markdwon
 
输出格式
 
设置render的output_format参数,可以将.Rmd文件呈现为R Markdown支持的任何格式,例如,下面的代码会将entropyM.Rmd呈现为Microsoft Word文档格式:
library(rmarkdown)
render("entropyM.Rmd", output_format = "word_document")看一下我们生成的word文档:

如果不设置格式,R Markdown会将文件呈现为默认格式,我们也可以在. Rmd文件开头的输出字段(output)中设置格式:
output: html_document 
我们也可以点击knit旁的下拉菜单,选择其他的输出格式:

 
输出选项
 
每个输出格式都是作为R中的函数来实现的,我们可以通过将参数作为输出字段(output)的子值传递给函数来定制输出:
output: 
  html_document:
    toc: true
    toc_float: true
    number_sections: true利用上述代码,我们可以生成一个包含数字标签的目录,且该目录悬挂在HTML文档的左侧:

 
html_document函数
 
- 描述
 
在R Markdown中,转换为HTML文档的格式。
 
- 用法
 
html_document(
  toc = FALSE,
  toc_depth = 3,
  toc_float = FALSE,
  number_sections = FALSE,
  section_divs = TRUE,
  fig_width = 7,
  fig_height = 5,
  fig_retina = 2,
  fig_caption = TRUE,
  dev = "png",
  df_print = "default",
  code_folding = c("none", "show", "hide"),
  code_download = FALSE,
  self_contained = TRUE,
  theme = "default",
  highlight = "default",
  mathjax = "default",
  template = "default",
  extra_dependencies = NULL,
  css = NULL,
  includes = NULL,
  keep_md = FALSE,
  lib_dir = NULL,
  md_extensions = NULL,
  pandoc_args = NULL,
  ...
) 
- 参数说明
 
参数  | 解释  | 
toc  | 若为ture,则在输出中包含一个目录  | 
toc_depth  | 在目录中包含的标题的深度  | 
toc_float  | 若为true,则将内容表浮动到主文档内容的左侧。  | 
number_sections  | 若为true,则在目录中增加数字标签  | 
fig_width  | 设置图形的默认宽度(英寸)  | 
fig_height  | 设置图形的默认高度(英寸)  | 
fig_retina  | 缩放来执行视网膜显示,可以设置为NULL以防止视网膜缩放  | 
fig_caption  | 若为true,则渲染带有字幕的图形  | 
df_print  | 用于打印数据框(data frame)的方法,有效值包括"default"、“kable”、“tibble"和"paged”。  | 
code_folding  | 允许文档阅读器切换R代码块的显示,指定"none"来显示所有代码块  | 
code_download  | 将Rmd源代码嵌入到文档中,并提供一个链接,供读者下载代码。  | 
self_contained  | 成一个没有外部依赖关系的独立HTML文件  | 
theme  | 视觉主题包括:“default”, “cerulean”, “journal”, “flatly”, “darkly”, “readable”, “spacelab”, “united”, “cosmo”, “lumen”, “paper”, “sandstone”, “simplex”, or “yeti”.  设置为NULL表示没有主题  | 
highlight  | 将语法突出的样式,支持的样式包括:“default”, “tango”, “pygments”, “kate”, “monochrome”, “espresso”, “zenburn”, “haddock”, and “textmate” .  设置为NULL表示没有主题  | 
css  | 需要包含的一个或多个css文件  | 










