Reputation: 47
library(ggplot2) #done this multiple times, and rmd works fine!
RIStopData<-read.csv("RIStopData.csv", sep=",")
p1 = ggplot(RIStopData, aes(x=driver_gender , y=as.numeric(stop_time)))
p1 + geom_boxplot()
This gives a nice boxplot when I ran the chunk in R markdown. But when I try to export this to html using knit
feature, R gives the following error on the second line itself:
Error in ggplot(RIStopData, aes(x=driver_gender , y=as.numeric(stop_time))) : could
not find function "ggplot" Calls: <Anonymous> ... handle-> withCallingHandlers ->
withVisible -> eval -> eval Execution halted
This is the boxplot I get in the markdown after running the code chunk.
Upvotes: 1
Views: 6841
Reputation: 887088
We tried to run the markdown with the inbuilt dataset mtcars
. The .rmd
file looks like below
---
title: "ggplot"
author: "akrun"
date: "February 13, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
```{r ggplot}
library(ggplot2)
data(mtcars)
p1 = ggplot(mtcars, aes(x=factor(gear) , y=mpg))
p1 + geom_boxplot()
```
-output
Upvotes: 1