[R] Advice on plotting a factor and displaying missing levels

obradoa aobradovic at gmail.com
Sat Jan 19 23:36:56 CET 2008

I am trying to plot how many records are inserted into a database on a
certain date, but also represent days where no records are inserted. I can
get a list of dates for inserted records using RMySQL 

result <- dbSendQuery(con, "select date_format(creation_ts, "%m/%d/%y") from
inserts<-fetch(res2, n=-1)
1  10/17/07
2  10/17/07
3  10/17/07
4  10/17/07
5  10/17/07
6  10/17/07
7  01/09/08
8  01/17/08
9  01/17/08
10 01/17/08

When I factor the "created" date column I get the following: 
> fcreated
 [1] 10/17/07 10/17/07 10/17/07 10/17/07 10/17/07 10/17/07 01/09/08 01/17/08
 [9] 01/17/08 01/17/08
Levels: 01/09/08 01/17/08 10/17/07

Then I plot the factor


The graph looks correct and I see how many records I have on which date. 

However, I need also to see dates where no records were found in the
database. So instead of having 3 levels 01/09/08 01/17/08 10/17/07, I need
to have the entire range of dates present on the graph starting with the
earliest date and finishing with the latest date. (For instance 10/17/07,
10/18/07.... up to the latest date 1/9/08.) Y axis values for those dates
should be 0, except for values tabulated in my factor variable "fcreated". 

Is this possible to do? 



View this message in context: http://www.nabble.com/Advice-on-plotting-a-factor-and-displaying-missing-levels-tp14976118p14976118.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list