楼主: oliyiyi
1895 1

Rmarkdown to Word Documents [推广有奖]

版主

已卖:2994份资源

泰斗

1%

还不是VIP/贵宾

-

TA的文库  其他...

计量文库

威望
7
论坛币
84105 个
通用积分
31671.0967
学术水平
1454 点
热心指数
1573 点
信用等级
1364 点
经验
384134 点
帖子
9629
精华
66
在线时间
5508 小时
注册时间
2007-5-21
最后登录
2025-7-8

初级学术勋章 初级热心勋章 初级信用勋章 中级信用勋章 中级学术勋章 中级热心勋章 高级热心勋章 高级学术勋章 高级信用勋章 特级热心勋章 特级学术勋章 特级信用勋章

楼主
oliyiyi 发表于 2016-6-18 15:00:01 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

To create a Word document from R Markdown you specify the word_document output format in the front-matter of your document:

---title: "Habits"author: John Doedate: March 22, 2005output: word_document---


Figure Options

There are a number of options that affect the output of figures within Word documents:

  • fig_width and fig_height can be used to control the default figure width and height (5x4 is used if not values are specified)

  • fig_caption controls whether figures are rendered with captions


For example:

---title: "Habits"output:  word_document:    fig_width: 5    fig_height: 5    fig_caption: true---


Syntax Highlighting

You can use the highlight option to control the syntax highlighting theme. For example:

---title: "Habits"output:  word_document:    highlight: "tango"---

Supported styles include “default”, “tango”, “pygments”, “kate”, “monochrome”, “espresso”, “zenburn”, and “haddock”. Pass null to prevent syntax highlighting.



Style Reference

You can also specify a document to be used as as a style reference in producing a docx file. For best results, the reference docx should be a modified version of a docx file produced using rmarkdown. Pass “default” to use the default styles. You can do this with the reference_docx option:

---title: "Habits"output:  word_document:    reference_docx: mystyles.docx---


Keeping Markdown

When knitr processes an R Markdown input file it creates a markdown (md) file which is subsequently tranformed into a Word document by pandoc. If you want to keep a copy of the markdown file after rendering you can do so using thekeep_md option:

---title: "Habits"output:  word_document:    keep_md: true---


Markdown Extensions

By default R Markdown is defined as all pandoc markdown extensions with the following tweaks for backward compatibility with the markdown package:

+autolink_bare_uris+ascii_identifier+tex_math_single_backslash

You can enable or disable markdown extensions using the md_extensions option (you preface an option with - to disable and + to enable it). For example:

---title: "Habits"output:  html_document:    md_extensions: -autolink_bare_uris+hard_line_breaks---

The above would disable the autolink_bare_uris extension and enable the hard_line_breaks extension.

For more on available markdown extensions see the pandoc markdown specification.



Pandoc Arguments

If there are pandoc features you want to use that lack equivilants in the YAML options described above you can still use them by passing custom pandoc_args. For example:

---title: "Habits"output:  word_document:    pandoc_args: [      "--csl", "/var/csl/acs-nano.csl"    ]---

Documentation on all available pandoc arguments can be found in the pandoc user guide.



Shared Options

If you want to specify a set of default options to be shared by multiple documents within a directory you can include a file named _output.yaml within the directory. Note that no YAML delimeters or enclosing output object are used in this file. For example:

_output.yaml

word_document:  fig_width: 5  fig_height: 5  fig_caption: true

All documents located in the same directory as _output.yaml will inherit it’s options. Options defined explicitly within documents will override those specified in the shared options file.



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:documents Document DOCUME Down word Documents Word

缺少币币的网友请访问有奖回帖集合
https://bbs.pinggu.org/thread-3990750-1-1.html

沙发
hjtoh 发表于 2016-6-18 15:40:15 来自手机
oliyiyi 发表于 2016-6-18 15:00
To create a Word document from R Markdown you specify the word_document output format in the front-m ...
谢谢分享

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-31 00:15