小编Jef*_*eff的帖子

在knitr中指定多个同时输出格式(新)

我可以编写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 …

yaml r knitr r-markdown

14
推荐指数
1
解决办法
2169
查看次数

将变量传递给tidyr的聚集以重命名键/值列?

我想tidyr::gather()在一个自定义函数内部调用,我传递一对将用于重命名keyvalue列的字符变量.例如

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)

r tidyr

6
推荐指数
1
解决办法
1856
查看次数

标签 统计

r ×2

knitr ×1

r-markdown ×1

tidyr ×1

yaml ×1