【问题标题】:R markdown error "object '...' not found", with dplyr [closed]R markdown错误“找不到对象'...'”,带有dplyr [关闭]
【发布时间】:2016-04-11 03:09:21
【问题描述】:

以下是 .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

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

【问题讨论】:

  • 范式是```{r chunk_label, options}
  • @rawr 你说得对,谢谢。

标签: r dplyr r-markdown


【解决方案1】:

正如@rawr 提到的,我忘了把“r”放在括号里。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-22
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 2020-12-26
    • 2017-06-12
    • 2018-08-15
    相关资源
    最近更新 更多