Skip to content

Broke ggplot...

8 messages · Jason Rupert, Hadley Wickham

#
On Mon, Feb 2, 2009 at 5:41 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
...

You can do this a bit more easily with:

VADeaths_flat_df <- melt(VADeaths)
names(VADeaths_flat_df) <- c("Age", "Person", "Data")
Those plots look fine to me (well they're what I'd expect from the
definition), but I'd think you'd want

ggplot(VADeaths_flat_df, aes(Data, fill = Person)) +
  geom_histogram(binwidth=20)

or maybe

ggplot(VADeaths_flat_df, aes(Person, weight = Data)) + geom_bar()
ggplot(VADeaths_flat_df, aes(Person, weight = Data, fill = Age)) + geom_bar()

Hadley
#
Hi Jason,

I can't see anyway to do this completely within in ggplot.  And it's
not easy to do the data processing yourself.  Here's one attempt that
almost works:

counts <- ddply(VADeaths_flat_df, .(round_any(Data, 20), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(bin, n, data = counts, fill = person, geom="bar", stat
="identity", position="dodge")

Or maybe:

counts <- ddply(VADeaths_flat_df, .(cut(Data,
breaks=fullseq(range(Data), 20)), Person), nrow)
names(counts) <- c("bin", "person", "n")

qplot(person, n, data = counts, fill = person, geom="bar", stat
="identity", width = 0.9) +
  facet_grid(. ~ bin) +
  opts(axis.text.x = theme_text(angle = 45, hjust = 1, colour = "grey60"))

Hadley
On Mon, Feb 2, 2009 at 8:32 PM, Jason Rupert <jasonkrupert at yahoo.com> wrote:

  
    
1 day later
#
On Wed, Feb 4, 2009 at 9:26 AM, Jason Rupert <jasonkrupert at yahoo.com> wrote:
The easiest way is + xlab("") or + xlab(NULL)

Hadley