Re: errors in stat_density

939 views
Skip to first unread message

Winston Chang

unread,
Sep 27, 2012, 4:40:17 PM9/27/12
to Styrkur Nams, ggp...@googlegroups.com
I think this is happening because there is a group (maturity==9) with only one observation. If you remove that row from the data set, it works fine.

ggplot should give a better error or warning in this case, so I filed an issue:

-Winston


On Thu, Sep 27, 2012 at 1:58 PM, Styrkur Nams <stat.d...@gmail.com> wrote:

 Dear all,

 This script worked two months ago, but now it doesn't and the only difference is that I updated the ggplot2 package:

qplot(lngtclass,data=ldm,geom="density",colour=maturity,adjust=0.15)

where x= lngtclass, and maturity is the aesthetic to subset the data.
        

I have tried several other examples from docs.ggplot2.org and I always get an error when I add the second aesthetic with geom_density or stat_density.  I get the following errors:


p <- ggplot(ldm, aes(lngtclass)) 
p + geom_density(aes(fill=factor(maturity)), size=2)

Error in rowSums(vapply(x, is.finite, logical(nrow(x)))) : 
  'x' must be an array of at least two dimensions
Error in if (nrow(layer_data) == 0) return() : argument is of length zero

If I try to use the old script, I get


Error in unit(tic_pos.c, "mm") : 'x' and 'units' must have length > 0

Any ideas?


Thanks!





--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Reply all
Reply to author
Forward
0 new messages