R markdown错误“对象'...'未找到”,与dplyr

时间:2016-04-11 03:09:22

标签: r dplyr r-markdown

以下是.rmd文件内容的一部分。

## Loading and preprocessing the data

Load the data with dplyr and data.table package into a data table called activity.
```{Load, echo=TRUE}
library(dplyr)
library(data.table)
activity<-fread("activity.csv")
```

The date has character type. Use lubridate to produce a POSIX typed date for further processing.
```{Change date, echo=T}
library(lubridate)
activity<-mutate(activity,POSIXdate=activity[,date])
```

## What is mean total number of steps taken per day?

Use summarize function in dyplyr package to sum up steps variable, with activity grouped by dates, and store it into a new data table called stepsPerDay.
```{Sum each day, echo=TRUE}
stepsPerDay<-summarize(group_by(activity,date),steps=sum(steps,na.rm=T))
```

Data table stepsPerDay looks like this:
```{r, echo=F}
head(stepsPerDay)
```

一切都运行正常,直到最后一行,它给了我错误

  

object 'stepsPerDay' not found Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> head In addition: Warning messages: 1: In get_engine(options$engine) : Unknown language engine 'Load' (must be registered via knit_engines$set()). 2: In get_engine(options$engine) : Unknown language engine 'Change' (must be registered via knit_engines$set()). 3: In get_engine(options$engine) : Unknown language engine 'Sum' (must be registered via knit_engines$set()). Execution halted

我试过了

head(stepsPerDay)

summary(stepsPerDay)

StepsPerDay

全部返回相同的错误。 我相信该对象是在markdown文件中生成的,所以应该在那里。我不知道为什么找不到这个对象。 谢谢你的帮助!

0 个答案:

没有答案