When tested with 'mtcars', markdown will have no problem knitting the code in html, however when I use the name of an imported data set:
```{r,echo = FALSE}
names(mtcars)
```
I get the following error:
Error in eval(expr, envir, enclos) : object 'Fitbit' not found
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Can anyone help me with why? I get an error every time I try to plot a chunk even though the test run went smoothly as well. If I use a chunk, I get an error with {r} or {r, echo = FALSE}.
Ex:
---
title: "Homework"
author: "name"
output: html_document
---
```{r,echo = FALSE}
names(Fitbit)
```
Output Error:
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
I am posting this as an answer for your convenience, I will delete it as soon as you try this out:
```{r}
setwd("C:/Users/nataliakhodayari/Desktop")
fitbit <- read.csv("Fitbit.csv")
names(fitbit)
hist(fitbit$Miles,xlab = "Miles",main = "Overall Miles Traveled")
```
If the directory cannot be changed, try this:
```{r}
fitbit <- read.csv("Fitbit.csv")
names(fitbit)
hist(fitbit$Miles,xlab = "Miles",main = "Overall Miles Traveled")
```