使用ggplot编织rmd文件时出错
Error while knitting rmd file with ggplot
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()
当我 运行 R markdown 中的块时,这给出了一个很好的箱线图。但是当我尝试使用 knit
功能将其导出到 html 时,R 在第二行本身给出了以下错误:
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
这是我在 运行 代码块之后在 markdown 中得到的箱线图。
我们尝试 运行 使用内置数据集 mtcars
降价。 .rmd
文件如下所示
---
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()
```
-输出
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()
当我 运行 R markdown 中的块时,这给出了一个很好的箱线图。但是当我尝试使用 knit
功能将其导出到 html 时,R 在第二行本身给出了以下错误:
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
这是我在 运行 代码块之后在 markdown 中得到的箱线图。
我们尝试 运行 使用内置数据集 mtcars
降价。 .rmd
文件如下所示
---
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()
```
-输出