我正在尝试使用csv NFL_DATA.csv创建一个R markdown。但是,当我尝试使用knitr
时,我收到错误:
nrow中的错误(NFL_DATA):对象' NFL_DATA'未找到电话: ... in_dir - > inline_exec - > withVisible - > eval - > eval - > nrow执行暂停
这是我的代码的开头:
title: "XXXXXX"
author: "XXXXXX"
date: "December 11, 2017"
output: html_document
font-family: "Arial"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
---
## Introduction
XXXXXXXXXXXXX.
---
## Data
We used the site data.world.com to find my data. The dataset can be retrieved at [NFL_DATA.csv](https://data.world/alice-c/nfl-fines-and-suspensions/workspace/file?filename=All+Penalties.csv).
There are `r nrow(NFL_DATA)` observations in the NFL data set and `r length(NFL_DATA)` variables. The variables are:
```{r echo=FALSE, comment=""}
names(NFL_DATA)
```
当我运行它时,knitr
不起作用并给出错误消息。但是,当我只运行names(NFL_DATA)
的最后一段代码时,它确实有效,并显示所有变量名称。我该如何解决这个问题?
答案 0 :(得分:0)
在编辑代码后尝试此操作指向本地存储csv文件的位置。
---
title: "NFL Fines and Suspensions Analysis"
author: "anAuthor"
date: "12/8/2017"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Read Data
Here is example code to read the nfl data
```{r readData,echo=FALSE}
nfldata <- read.csv("./data/All Penalties.csv",header=TRUE)
```
There are `r nrow(nfldata)` observations in the NFL data set and `r length(nfldata)` variables. The variables are:
```{r}
names(nfldata)
```