Skip to content
Prev 164294 / 398506 Next

xyplot sorted by date

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.