Skip to content

xyplot sorted by date

2 messages · Ptit_Bleu, Stefan Grosse

#
Hello

I have a dataframe with 3 columns C1, C2 and C3.
C1 and C2 are numerical data and C3 is the date of the data (format :
%Y-%m-%d %H:%M:%S")

With the lattice package, I would like to plot C1 as function of C2 sorted
by the dates, that is something like :
xyplot(C1 ~ C2 | as.Date(C3))

It plots somethings but not the truth.
I have compared the output with the output of this script

x11(15,12)
layout(matrix(1:4,2,2)
plot(C1[C3=='2008-12-06'] ~ C2[C3=='2008-12-06'])
plot(C1[C3=='2008-12-07'] ~ C2[C3=='2008-12-07'])
plot(C1[C3=='2008-12-08'] ~ C2[C3=='2008-12-08'])
plot(C1[C3=='2008-12-09'] ~ C2[C3=='2008-12-09'])

which gives the good curves but it is not as nice as with lattice.

Could you please tell me how to solve my problem ?
Thanks in advance,
Ptit Bleu.
#
I don't know whether it is ther perfect way but I did something similiar
with using a factor. So you could use factors from 1:(number of days)
and the dates as factor labels. But maybe there is a better way.


hth
Stefan

ps I would be interested in "truth" plotting if someone has a function
it could substitute parts of my reserach ;-)