[R] lines and dates

Jean Eid jeaneid at chass.utoronto.ca
Thu Feb 5 01:38:56 CET 2004


Dear All,
I have the following data.frame

`data.frame':	1563 obs. of  4 variables:
 $ Model      :Class 'AsIs'  chr [1:40] "Astro" "Astro" "Astro" "Astro"
 $ Make       :Class 'AsIs'  chr [1:40] "Chevrolet" "Chevrolet"
 $ Production : num  11219 12384  1082  5409  5458 ...
 $ date       :`POSIXlt', format: chr  "2000-05-01" "2000-06-01"


The data frame contains production levels of some cars from 2000 to 2003.
My question is about plotting production for  each  model.
I have a code that  outputs a plot for each model and
it works fine.  However I would like to plot couple of models together i.e
when I do

plot(temp$date, temp$Production, type="n")
by(temp, list(temp$Model), function(x) lines(x[, "date"], x[,
"Production"]))

I get an error:
      Error in xy.coords(x, y) : x and y lengths differ

I believe that it has something to do with POSIXlt. when I issue a length
or NROW command on temp$date it returns the value 9.

any help is greatly appreciated,

Jean




More information about the R-help mailing list