Markdown在编织时没有找到参数

时间:2017-03-16 04:59:06

标签: r r-markdown

当我尝试编织以下文件时

----
title: "jerHW52"
output: html_document
params:
  missiontype: "Successful.Unmanned"
---

```{r warning=FALSE,echo=FALSE}
knitr::opts_chunk$set(echo=FALSE)
library(tidyr)
library(ggplot2)
Launch_Data<-read.csv("NASA_Launch_Data.csv",header=TRUE)
NASA_Launch_Data<- Launch_Data %>% filter(Launch_Data$Type==params$missiontype)
ggplot(NASA_Launch_Data, aes(x=Year, y=Missions)) + geom_line() 
```

我收到以下错误

  

过滤器中的错误(。,Launch_Data $ Type == params $ missiontype):object   &#39; PARAMS&#39;未找到电话:... _fseq - &gt; freduce - &gt;   withVisible - &gt; - &GT; filter执行暂停

为什么它找不到params?

以下是NASA_Launch_Data.csv

中数据的开头
"","Year","Type","Missions"
"1",1957,"Successful.Unmanned",3
"2",1958,"Successful.Unmanned",28
"3",1959,"Successful.Unmanned",23
"4",1960,"Successful.Unmanned",40
"5",1961,"Successful.Unmanned",48
"6",1962,"Successful.Unmanned",76
"7",1963,"Successful.Unmanned",67
"8",1964,"Successful.Unmanned",99
"9",1965,"Successful.Unmanned",119
"10",1966,"Successful.Unmanned",129

1 个答案:

答案 0 :(得分:2)

答案是我是个白痴......

请注意我文档顶部的YAML标题

----
title: "jerHW52"
output: html_document
params:
  missiontype: "Successful.Unmanned"
---

第一行有四个破折号,而不是应该有三个破折号。删除一个,一切正常......