我经常使用ggplot2软件包安装我的图表,包括内核密度图。到目前为止,我没有遇到过奇怪的错误,但现在我有了:
as.environment(where)中的错误:'其中'缺少*
我的数据向量中包含负值,范围从-1000到-100。对于正值,同一段代码正在工作,但不适用于负值。以下是小插曲:
sign <- c(-1000, -800, -700, -100, -500, -250, -100, -850, -100, -700)
p <- ggplot(plot_data, aes(x=sign, fill=Status)) + geom_density(alpha = 0.5) + xlab ("Signature")+ ylab("Density")
以下是dput
数据框的plot_data
。
structure(list(Sample = c(107453L, 107458L, 107457L, 107462L,
107454L, 107459L, 107455L, 107460L, 107456L, 107461L), Status = c("Control",
"Control", "CyP Treated (1 Hr)", "CyP Treated (1 Hr)", "CyP Treated (3 Hrs)",
"CyP Treated (3 Hrs)", "LPS Treated (3 Hrs)", "LPS Treated (3 Hrs)",
"Cyp+LPS Treated (3 Hrs)", "Cyp+LPS Treated (3 Hrs)"), sign = c(-1000L,
-800L, -700L, -100L, -500L, -250L, -100L, -850L, -100L, -750L
)), .Names = c("Sample", "Status", "sign"), class = "data.frame", row.names = c(NA, -10L))
任何人都可以帮助我解决这个问题,因为没有一个值是NA吗?
答案 0 :(得分:0)
使用您的数据框和此代码(示例的详细版本):
p <- ggplot(plot_data, aes(x=sign, fill=Status))
p <- p + geom_density(alpha=0.5)
p <- p + xlab ("Signature") + ylab("Density")
p <- p + theme_bw()
p
我得到的错误(与你的错误不同)是:
Error in exists(name, env) : argument "env" is missing, with no default
如果我重新创建数据框,但每Status
添加一个额外的样本:
set.seed(1492)
nsamp=3
dat <- data.frame(Status = rep(c("Control", "CyP Treated (1 Hr)",
"CyP Treated (3 Hrs)", "LPS Treated (3 Hrs)",
"Cyp+LPS Treated (3 Hrs)"), each=nsamp),
sign = sample(seq(-1000, -100, by=50), 5*nsamp, replace=TRUE))
p <- ggplot(dat, aes(x=sign, fill=Status))
p <- p + geom_density(alpha=0.5)
p <- p + xlab ("Signature") + ylab("Density")
p <- p + theme_bw()
p
我明白了:
(每Status
只有2个读数的生成数据框失败的方式与原始数据相同。)
如果每dput(plot_data)
个读数更多,您可以粘贴Status
吗?