[R] ggplot2

AlexPiche alexandre.piche at mail.mcgill.ca
Thu Jul 4 16:00:10 CEST 2013


Hello Folks,

I have a database of 2000+ days with 35 observations each. I am trying to
modeling a time series by day, but it seems a problem that I don<t have the
time of the observation. I achieve something interesting by using the
barplot function, but I`d rather working with ggplot2, since I have the book
by Hadley Wickham in hands. 


I start by transforming my data into a dataframe, but since I have even more
problems working with my data, since all my observations are plot on the
same day.

> str(last(dezdiff))
An ‘xts’ object on 2013-07-04/2013-07-04 containing:
  Data: num [1, 1:35] 1.9016 0.7545 0.225 0.0727 0.1357 ...
 - attr(*, "dimnames")=List of 2
  ..$ : NULL
  ..$ : chr [1:35] "1" "2" "3" "4" ...
  Indexed by objects of class: [Date] TZ: UTC
  xts Attributes:  
 NULL

>barplot(last(dezdiff), beside = TRUE)

<http://r.789695.n4.nabble.com/file/n4670852/barplot.bmp> 

> str(dezdiff.dt)
'data.frame':   2741 obs. of  36 variables:
 $ datetime: Date, format: "2003-01-02" "2003-01-03" "2003-01-06"
"2003-01-07" ...
 $ X1      : num  5.63 -1.42 -6.8 -1.9 -6.17 ...
 $ X2      : num  7.748 -0.296 -5.333 -2.348 -5.323 ...
 $ X3      : num  9.075 0.454 -4.294 -2.557 -5 ...
 $ X4      : num  9.863 0.966 -3.542 -2.629 -4.978 ...
...
 $ X32     : num  11.21 1.38 2.44 -3.48 -6.04 ...
 $ X33     : num  11.26 1.24 2.52 -3.47 -6.05 ...
 $ X34     : num  11.3 1.1 2.59 -3.45 -6.06 ...
 $ X35     : num  11.337 0.956 2.658 -3.436 -6.075 ...

qplot(datetime, c(X1:X35), data=dezdiff.dt[nrow(dezdiff.dt),])

<http://r.789695.n4.nabble.com/file/n4670852/ggplot2.bmp> 

Anyone know how I could reshape my data or just how I would be able to plot
all my observations on the same graph at different position on the x-axis.

Thank you for your time, and let me know if you have any question.

Regards,

Alex



--
View this message in context: http://r.789695.n4.nabble.com/ggplot2-tp4670852.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list