我可以编写YAML标头,使用knitr为R Markdown文件生成多种输出格式吗?我无法使用此标题重现原始问题的答案中描述的功能.
这个降价文件:
---
title: "Multiple output formats"
output:
pdf_document: default
html_document:
keep_md: yes
---
# This document should be rendered as an html file and as a pdf file
Run Code Online (Sandbox Code Playgroud)
生成pdf文件,但没有HTML文件.
而这个文件:
---
title: "Multiple output formats"
output:
html_document:
keep_md: yes
pdf_document: default
---
# This document should be rendered as an html file and as a pdf file
Run Code Online (Sandbox Code Playgroud)
生成HTML文件(和md文件),但没有pdf文件.
后一个例子是给出原始问题的解决方案.我尝试使用Shift-Ctrl-K和RStudio中的Knit按钮编织,以及调用rmarkdown::render,但只创建一个输出格式,而不管我用来生成输出文件的方法.
可能相关,但我无法确定解决方案:
使用R版本3.3.1(2016-06-21),knitr …
我想tidyr::gather()在一个自定义函数内部调用,我传递一对将用于重命名key和value列的字符变量.例如
myFunc <- function(mydata, key.col, val.col) {
new.data <- tidyr::gather(data = mydata, key = key.col, value = val.col)
return(new.data)
}
Run Code Online (Sandbox Code Playgroud)
但是,这不能按预期工作.
temp.data <- data.frame(day.1 = c(20, 22, 23), day.2 = c(32, 22, 45), day.3 = c(17, 9, 33))
# Call my custom function, renaming the key and value columns
# "day" and "temp", respectively
long.data <- myFunc(mydata = temp.data, key.col = "day", val.col = "temp")
# Columns have *not* been renamed as desired
head(long.data) …Run Code Online (Sandbox Code Playgroud)