R:来自ggplot2的qplot中的错误:参数“env”缺少,没有默认值 [英] R: error in qplot from ggplot2: argument "env" is missing, with no default

查看:706
本文介绍了R:来自ggplot2的qplot中的错误:参数“env”缺少,没有默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ggplot2的qplot来绘制R中不同物种分散种子的距离。当我使用 geom ='density'时,它工作得很好!但是我真正想要的是一个频率/面积图,对此我得到一个我不知道如何解决的错误。

I am using qplot from ggplot2 to plot the distances of seeds dispersed by different species in R. When I use geom='density', it works just fine! But what I really want is a frequency/area plot, for which I get an error I do not know how to address.

这是有效的:

qplot(Dist,data=testx,geom="density",fill=Animal,log=c('x','y'),alpha=I(0.5))

这是行不通的:

qplot(Dist,data=testx,geom="area",fill=Animal,log=c('x','y'))

Error in exists(name, envir = env, mode = mode) : 
  argument "env" is missing, with no default

帮助?感谢!

推荐答案

关于此错误消息,可能有助于指出这是您使用空为直方图设置的数据:

Regarding this error message it might help to point out that this is the error message you get when you use an empty data set for a histogram:

df <- data.frame(testx = rnorm(0))
p <- ggplot(df, aes(x=testx)) +
  geom_histogram()
plot(p)

Error in exists(name, envir = env, mode = mode) : 
  argument "env" is missing, with no default

不幸的是,错误信息在这种情况下根本没有什么帮助。当我第一次遇到这个问题时,花了一些时间才发现我只是意外地结束了一个空的数据框。 OP可能有一个不同的问题,但总是很高兴知道这个错误与这个愚蠢的错误有关。

Unfortunately, the error message is not very helpful at all in this case. When I first ran into this problem it took me some time to figure out that I just accidentally had ended up with an empty data frame. The OP probably had a different problem, but it is always good to know that this error is connected to this stupid mistake.

这篇关于R:来自ggplot2的qplot中的错误:参数“env”缺少,没有默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆