[R] plotting date data over couple of months

David Winsemius dwinsemius at comcast.net
Thu Jul 14 02:17:57 CEST 2011



So, post some data. I'm tired of unsuccessful attempts at mind  
reading. If the data set is too big, then just use:

dput(data2[which( data2$date < as.Date("2011-05-05") &
                                           data2$date >  
as.Date("2011-04-27") ),
           ]
     )

-- 
David




On Jul 13, 2011, at 8:09 PM, vamshi999 wrote:

> I am sorry i was not clear in my early post....
>
> I have used the below code to change my data into date format..
>
> r<-as.POSIXlt(paste(data2$date,data2$time))
> library(gsubfn)
> library(chron)
> r<-as.chron(r)
>
> data2$date<-strftime(strptime(r, format="(%m/%d/%y %H:%M:%S)"),"%Y- 
> %m-%d")
> data2$time<-strftime(strptime(r, format="(%m/%d/%y %H:%M:%S)"),"%H: 
> %M:%S")
>
> now i have a date variable in the below format..
>
> "2011-04-20"
>
> while plotting dates using the above format.. i was getting the x- 
> axis in
> this way..
>
>        ----------------------
>        2011-04-29    2011-05-05
>
> but i want the values in my x-axis to be in this format..
>
>                 ------------------
>               27 28 29 30 1 2 3 4
>               April             May
>
>
> about the error plots.... i was not able to compute the mean and sd  
> values
> ..
>
> My data has  the following columns..
>
> date, time, height..
>
> this is the bird data which we recorded.. so i have date, time,  
> height at
> which the birds are being detected . so now i want to plot errorbar  
> for
> total no.of birds detected on each day..
>
> for a simple plot ..i used.. counts<-table(data$date).. i was able  
> to get
> the count on each day..
>
> then.. barplot(counts).. but i was not able to calculate the mean  
> and sd for
> counts..
>
> thank you


David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list