[R] ggplot2

John Kane jrkrideau at inbox.com
Thu Jul 4 16:36:51 CEST 2013


I think we need to see some of the original data. See ?dput for how to supply data in a email.  

We probably don't need all the data, I'd suggest perhaps 100 rows or so.  Try dput(head(yourdata, 100))

BTW what is "last"?

John Kane
Kingston ON Canada


> -----Original Message-----
> From: alexandre.piche at mail.mcgill.ca
> Sent: Thu, 4 Jul 2013 07:00:10 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] ggplot2
> 
> 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.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails



More information about the R-help mailing list