indexing dates

Gunter, Bert (
Fri, 16 Jan 1998 12:54:44 -0500

Please reply to me personally, and I shall summarize anything of
interest to the list.

I am in Splus 4.0 (v2) under Windows NT 4.0.

1) I have a data frame read in from an excel spreadsheet. One column,
c1, has dates as character strings. Another column, c2, has integers
which are lots within date(and are all<10). There are variable numbers
of rows (samples from) each lot within date and the dates are not
regular nor is the file in order. I shall eventually wish to plot a
column of numeric data by lots within dates in order (the x-axis
labeling is unimportant).That is, at each x plotting position the
replicate values for a lot within date will be plotted, in order of
dates and lots within dates.

To do this I believe I need to create an index variable that increases
in the above order. Is there any cleverer alternative (maybe using plot
methods for time series)? My approach seems crude and un-S-like.

2) Because my text (date) columns got converted to unordered factors
when I read in the excel spreadsheet (can't avoid with I() construction
in the Import ), I use the following laborious construction to convert
the dates column to an ordered factor and construct my index variable
from their codes. Is their a better way to do this (irrespective of the
answer to 1))? It seems really dumb. Note that I used the construction
levels(c1)[codes(c1)] to unclass my dates column so the dates function
can be applied to order it.


#can now easily convert these indices to values in
1:length(unique(index)) for plotting.


Bert Gunter
Biometrics Research
Merck Research Labs
P.O. Box 2000
Rahway, NJ 07065-0900

"The business of the statistician is to catalyze the
scientific learning process." George E. P. Box