gpt4 book ai didi

r - 编织时 Markdown 找不到参数

转载 作者:行者123 更新时间:2023-12-05 03:09:26 26 4
gpt4 key购买 nike

当我尝试编写以下文档时

----
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()
```

出现以下错误

Error in filter(., Launch_Data$Type == params$missiontype) : object 'params' not found Calls: ... _fseq -> freduce -> withVisible -> -> filter Execution halted

为什么找不到参数?

这是 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

最佳答案

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

注意我文档顶部的 YAML header

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

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

关于r - 编织时 Markdown 找不到参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42825636/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com