使用' mtcars'进行测试时,markdown在编写html代码时没有问题,但是当我使用导入数据集的名称时:
```{r,echo = FALSE}
names(mtcars)
```
我收到以下错误:
Error in eval(expr, envir, enclos) : object 'Fitbit' not found
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
任何人都可以帮我解释原因吗?每次尝试绘制块时都会出错,即使测试运行顺利也是如此。如果我使用一个块,我会收到{r}或{r,echo = FALSE}的错误。
例如:
---
title: "Homework"
author: "Natalia"
output: html_document
---
```{r,echo = FALSE}
names(Fitbit)
```
输出错误:
Quitting from lines 9-10 (Example-Homework-Problem.Rmd)
Error in eval(expr, envir, enclos) : object 'fitbit' not found
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
答案 0 :(得分:0)
为了您的方便,我发布此答案作为答案,我会在您尝试后立即将其删除:
```{r}
setwd("C:/Users/nataliakhodayari/Desktop")
fitbit <- read.csv("Fitbit.csv")
names(fitbit)
hist(fitbit$Miles,xlab = "Miles",main = "Overall Miles Traveled")
```
如果目录无法更改,请尝试以下操作:
```{r}
fitbit <- read.csv("Fitbit.csv")
names(fitbit)
hist(fitbit$Miles,xlab = "Miles",main = "Overall Miles Traveled")
```