I was using ggplot version 0.8.3 to make histograms with negative
counts by using a negative weight but have just upgraded to 0.8.5 and
it doesn't now work, instead giving me an error. The reason I am
doing this is so I can have back-to-back histograms with certain
levels of a factor positive and certain ones negative.
A simple example:
ggplot(diamonds, aes(color, fill=cut)) + geom_bar(aes(weight = -1))
gives the error
Error in `[<-.data.frame`(`*tmp*`, var, value = list(`NA` = NULL)) :
missing values are not allowed in subscripted assignments of data
frames
More fully, I'd like to run something like
ggplot(diamonds, aes(color, fill=cut)) + geom_bar(subset = .(cut ==
"Fair" | cut == "Good"), aes(weight = -1)) + geom_bar(subset = .(cut
== "Premium" | cut == "Ideal"), aes(weight = 1))
Any clues?
Thanks!
--
You received this message because you are subscribed to the ggplot2 mailing list.
To post to this group, send email to ggp...@googlegroups.com
To unsubscribe from this group, send email to
ggplot2+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ggplot2
Andrea
On Dec 24, 3:13 pm, Luciano Selzer <luciano.sel...@gmail.com> wrote:
> Hi Andrea, maybe you can look a post at learn R blog. Maybe it will help
> you.http://learnr.wordpress.com/2009/09/24/ggplot2-back-to-back-bar-charts/
>
> <http://learnr.wordpress.com/2009/09/24/ggplot2-back-to-back-bar-charts/>
> Luciano
>
Yes, I'd definitely recommend that technique - negative weights are
not meaningful.
Hadley
diam.tab = with(diamonds, table(cut,color))
diam.summ = as.data.frame(diam.tab)
ggplot(diam.summ, aes(color, fill=cut)) + geom_bar(subset = .(cut ==
"Fair" | cut == "Good"| cut == "Very Good"), aes(y = -Freq)) + geom_bar
(subset = .(cut == "Premium" | cut == "Ideal"), aes(y = Freq))
Thanks
Andrea