【发布时间】:2018-02-13 06:32:18
【问题描述】:
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中得到的箱线图。
【问题讨论】:
-
安装后请加载库,即
library(ggplot2)(如果未安装) -
多次这样做只是为了确定。但不要认为这是问题,因为代码块运行并绘制箱线图就好了。
-
您的错误状态为
could not find function "ggplot" -
是的,但这就是我检查库是否已加载的原因。无论如何再次加载它,但我仍然得到同样的错误。 rmd 文件使用
ggplot运行,因此库被加载。 -
is
library(ggplot2)在你 rmd 上的 r 块中?
标签: r function ggplot2 r-markdown knitr