Hi R-Users,
I have a time series of bivariate observations (x,y,t). I've
developed a few panel routines to explore certain aspects of the data,
and now would like to break the time series up into smaller chunks to
explore the temporal trends. I would like to know if anyone has any
experience breaking up time series with lattice.
Base graphics offers coplot, utilizing the co.intervals routine to
break up the series into equal chunks. Lattice has equal.count as a
wrapper for co.intervals. As you can see in the example below, I can
recreate a 'coplot' with lattice but am having difficulty getting the
x-axis of the shingle plot and the strip labeling on the xyplot to be
in time or date format. My question really consists of two parts,
with the second part being less important for my data visualization
purposes:
1) How might I be able to convert the x-axis of the shingle plot from
numeric to date format?
2) How might I be able to customize the strip labels on the xyplot to
show a range, like min(month, year)-max(month, year) for each panel?
Thank you very much for any helpful suggestions.
Jon
#########################################
# Example R script
library(lattice)
times<-as.Date(seq(11400,14190,
length.out=100),origin="1970-01-01")
x<-rnorm(100)
y<-rnorm(100)
df<-data.frame(x=x,y=y,times=times)
#I want to recreate something like coplot with lattice
coplot(y~x|times,data=df)
#this doesn't work, which is an issue with co.intervals
breaks<-equal.count(times)
#this does work
breaks<-equal.count(unclass(times))
#In the lattice book there is this outline
bPlot<-plot(breaks)
dPlot<-xyplot(y~x|breaks, data=df)
plot(bPlot, position=c(0,0.65,1,1))
plot(dPlot, position=c(0,0,1,0.65),newpage=FALSE)
#The plot is ok, but the xaxis is in numeric and not date
#########################################
Jon Loehrke
Graduate Research Assistant
Department of Fisheries Oceanography
School for Marine Science and Technology
University of Massachusetts
200 Mill Road, Suite 325
Fairhaven, MA 02719
jloehrke@umassd.edu
> sessionInfo()
R version 2.8.1 (2008-12-22)
i386-apple-darwin8.11.1
locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grid stats graphics grDevices utils datasets
methods base
other attached packages:
[1] lattice_0.17-17
[[alternative HTML version deleted]]