[R] Yet another beginner question

Heywood, Giles Giles.Heywood at CommerzbankIB.com
Tue Sep 9 08:55:44 CEST 2003


The Irregular Time-Series ('its') class could be helpful to you.
The following does the basics of what you have asked.

require(its)
its.format("%m/%d/%y")
myits <-
its(cbind(reelect,new),dates=as.POSIXct(x=strptime(dateofpoll,format=its.for
mat())))
plot(myits,type="b")

You may want to customise the graphical parameters using par(), 
or passing extra parameters to plot() which will pass them through,
to axis.POSIXct, for example to control the number of x-axis ticks, 
which in this example defaults to 1.

On the smoothing issue, I can't really help.

The its package is to be found on CRAN.

Giles
> -----Original Message-----
> From: Peter Flom [mailto:flom at ndri.org]
> Sent: 08 September 2003 22:08
> To: r-help at stat.math.ethz.ch
> Subject: [R] Yet another beginner question
> 
> 
> Thanks for all the help on my earlier questions.....
> 
> 
> How do you plot a simple time series with unequal intervals?  I have
> the following
> 
> dateofpoll <- as.ts(c("6/1/02", "7/1/02", "10/1/02", "1/4/03",
> "1/25/03",
> "6/7/03", "7/16/03", "8/17/03", "9/4/03"))
> reelect <- c(51, 47, 49, 51, 49, 49, 46, 45, 40)
> new <-     c(28, 32, 35, 36, 41, 38, 47, 48, 52)
> 
> what I'd like is to plot reelect and new  (maybe with smoothing) on a
> time scale, with the x axis labeled for date.....
> 
> But I can't figure out how, despite looking at ?ts and various things
> there
> 
> 
> Thanks in advance
> 
> 
> 
> 
> 
> Peter L. Flom, PhD
> Assistant Director, Statistics and Data Analysis Core
> Center for Drug Use and HIV Research
> National Development and Research Institutes
> 71 W. 23rd St
> www.peterflom.com
> New York, NY 10010
> (212) 845-4485 (voice)
> (917) 438-0894 (fax)
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


********************************************************************** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}




More information about the R-help mailing list