If you put NA instead of 0, then the line will 'break' when there is no data. I don't know if this is better than going down to zero in the case of missing data; you will have to decide. If you already have NAs, then you can replace these with zeros.
On Jan 19, 2008 10:25 PM, obradoa <[EMAIL PROTECTED]> wrote: > > Great, this would work. Is it also possible to plot zero values for each > missing day, so when I do the line graph it properly drops to 0 if there was > no data for that day? Currently the line graph connects dots that represent > days with data present, but the line graph never drops to 0. I'd appreciate > if you have any suggestions for this. > > Thanks for you, > > Alex > > > Gabor Grothendieck wrote: > > > > Tabulate using table(), convert the dates to Date class and plot: > > > > f <- factor(c("10/17/07", "10/17/07", "10/17/07", "10/17/07", "10/17/07", > > "10/17/07", "01/09/08", "01/17/08", "01/17/08", "01/17/08")) > > > > ndays <- table(f) > > plot(as.Date(names(ndays), "%m/%d/%y"), ndays) > > > >> 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 > >> mytable;") > >> inserts<-fetch(res2, n=-1) > >> >inserts > >> created > >> 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 > >> > >> plot(fcreated) > >> > >> 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". > > > > > > -- > View this message in context: > http://www.nabble.com/Advice-on-plotting-a-factor-and-displaying-missing-levels-tp14976118p14978080.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.