r - Density plot for negative values with ggplot2 -
i using ggplot2 package quiet graphs, including kernel density plot. far had not encountered weird error, have:
error in as.environment(where) : 'where' missing *
i have data vector having negative values in it, ranging -1000 -100. positive values same piece of code working not negative values. below vignette:
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")
here dput
of plot_data
data frame.
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))
can please me out this, since none of value na?
with data frame , code (a broken out version of example):
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
the error (which different yours) is:
error in exists(name, env) : argument "env" missing, no default
if re-create data frame add 1 sample per 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
i this:
(the generated data frame 2 readings per status
fails same way original).
can paste dput(plot_data)
in event there more readings per status
?
Comments
Post a Comment