Skip to content
Prev 58386 / 398502 Next

plot time series / dates (basic)

Thank you for the suggestions. I managed to fix everything except the
first part. 
	dat <- date[(j-1)*points+1):(j*points)]
causes a syntax error. If I do 
	dat <- vector() 
I end up with numbers (which is fine by me - just like SAS dates).
However, after checking a couple of sources I still have no idea how
to format numbers as dates (for plotting/printing). Does anyone have
an example for formatting 12710 (# of days since 1 Jan 1970) as
19-Oct-04 (in the x axis of a plot)?

Regards,
b.


#function to plot a long time series piece by piece
pl <- function(vara, varb, points)
	{
	date <- as.Date(as.character(Date), "%d-%b-%y")
	pr1 <- vector(mode="numeric")
	pr2 <- vector(mode="numeric")
	#dat <- vector()
	dat <- date[(j-1)*points+1):(j*points)]
	for (j in 1:(round(length(Vol)/points)+1)) #number of plots
		{
		for (i in ((j-1)*points+1):(j*points)) 
			{
			pr1[i-points*(j-1)] <- vara[i]
			pr2[i-points*(j-1)] <- varb[i]
			#dat[i-points*(j-1)] <- date[i]
			#dat <- date[i]
			}
		par(mfrow=c(2,1), mai=c(0.4, 0.5, 0.3, 0.1), omi=c(0.2, 0, 0, 0), 
			cex.axis=0.7, cex=1.2, cex.main=0.7, pch="*") 
		plot(dat, pr1, main=deparse(substitute(vara)), type="o")
		#axis.Date(1,dat,format="%b%y") 
		plot(dat, pr2, main=deparse(substitute(varb)), type="o")
		}
	}
--- Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

            
__________________________________