[R] ggplot2: line plot with gaps in time axis

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Sep 4 09:22:54 CEST 2008


Brian,

The easiest way is to create the entire timeseries and then set the
missing values to NA. The NA values will lead to the gaps you want.

HTH,

Thierry 


------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
Thierry.Onkelinx op inbo.be 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-----Oorspronkelijk bericht-----
Van: r-help-bounces op r-project.org [mailto:r-help-bounces op r-project.org]
Namens btcruiser
Verzonden: woensdag 3 september 2008 20:33
Aan: r-help op r-project.org
Onderwerp: [R] ggplot2: line plot with gaps in time axis


Hello, I'm trying to plot data that has gaps in the timeline because my
data
only has the business day in it. When I do a line plot I get the data
and
then a blank area where a line goes the tail of the last data point  to
the
head of the next data point. Is there a way I can do a line plot where
the
gaps are not plotted?

Thanks in advance, 

Brian

> names(utildf)
[1] "Date_and_Time" "Utilization"   "Direction"    
> utildf
           Date_and_Time Utilization Direction
1    2008-08-25 05:00:00    5.862601   Inbound
2    2008-08-25 05:05:00   10.025328   Inbound
3    2008-08-25 05:10:00    5.794900   Inbound
4    2008-08-25 05:15:00    9.862726   Inbound
5    2008-08-25 05:20:00    4.150328   Inbound
6    2008-08-25 05:25:00    5.559362   Inbound
[...]

# startDateTime and stopDateTime is user entered
Start <- as.numeric(as.POSIXct(startDateTime))
End <- as.numeric(as.POSIXct(stopDateTime))
Period<-as.numeric(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
Labels<-as.Date(seq.POSIXt(as.POSIXct(Start,origin="1970-1-1"),
as.POSIXct(End,origin="1970-1-1"), by="DSTday"))
dt <-
qplot(as.numeric(utildf$Date_and_Time),Utilization,data=utildf,colour=Di
rection,geom="segment")
dt + scale_x_continuous(breaks=Period,label=Labels)

-- 
View this message in context:
http://www.nabble.com/ggplot2%3A-line-plot-with-gaps-in-time-axis-tp1929
5209p19295209.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help op 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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.%CRLF%The views expressed in  this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document%CRLF%



More information about the R-help mailing list