views:

96

answers:

2
+3  Q: 

time series in R

hello,
here is my question:
i have these data

 summary(data)

   Date                  
 1990/01:  1                
 1990/02:  1               
 1990/03:  1                
 1990/04:  1               
 1990/05:  1               
 1990/06:  1               
 (Other):242               

  attribute
 Min.   :164.9  
 1st Qu.:201.5  
 Median :244.1  
 Mean   :274.6  
 3rd Qu.:313.3  
 Max.   :512.1  
 NA's   :  1.0  

and i want to draw a time series plot

so i tried this:

qplot(as.Date(Date, "%Y/%m/%d"), attribute, data = data, geom = "line", main="Attribute per month 1990-2010", xlab="month-year", ylab="attribute" , colour = I("steelblue4"),fill = I("steelblue4"))

and i got:
Error in seq.int(r1$year, to$year, by) : 'from' must be finite
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

any ideas to solve it?

thank you

+2  A: 

This conversion as.Date(Date, "%Y/%m/%d") gives you NA for all values.

Try as.Date(paste(Date,"01",sep="/"), "%Y/%m/%d").

Marek
A: 

thanx a lot Marek!
this looks to work, BUT now the problem lies on the labels of dates (x-axis)...what should i do if i want year and month to be printed?

Eleftheria
If I run you line (for fake data) I got year and month. So I can't help you with that.
Marek