graph bar of counts vs total data

11 views
Skip to first unread message

Ken Mwai

unread,
Nov 11, 2013, 9:38:30 AM11/11/13
to ggp...@googlegroups.com
Hi All;
I am using R 3.0.2 on a 64bit machine
I have a data set of with data from 1989-2011 with date, age in months, serialno and admission ward

I want to do a graph of the total data (serialno) vs date over the years.
I am trying to use

ggplot(dta, aes(nagem , fill=admin_ward)) + geom_bar() +
  facet_grid(. ~ yr, scales = "free",margins=F) + geom_histogram(binwidth=300)

nagem - age in months
admin_ward - admision ward
yr - year


how can i include the serialno to be part of the graph to achieve a plot as shown below in ggplot2



Doug Mitarotonda

unread,
Nov 11, 2013, 11:29:12 AM11/11/13
to Ken Mwai, ggplot2
It would be easiest to help if you provided a reproducible example, but in general you will want to use position = "dodge", which is documented here: http://docs.ggplot2.org/0.9.3.1/position_dodge.html

Also, why are you using geom_bar and geom_histogram?



--
--
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
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Ken Mwai

unread,
Nov 11, 2013, 11:48:59 PM11/11/13
to Doug Mitarotonda, ggplot2
Thanks Doug;
I am using geombar() to facilitate addition of layers and geomhistogram() for controling the binwidth of each year

Kind Regards
Ken Mwai
www.keniajin.com
"Stats don't lie and technology is a lyfstyle live it"

Doug Mitarotonda

unread,
Nov 12, 2013, 12:30:17 AM11/12/13
to Ken Mwai, ggplot2
My guess is that you don't need both if you do something like geom_bar(position = "dodge"). 
Reply all
Reply to author
Forward
0 new messages