[R] plotting date data over couple of months
David Winsemius
dwinsemius at comcast.net
Thu Jul 14 02:57:17 CEST 2011
On Jul 13, 2011, at 8:32 PM, vamshi999 wrote:
> I am sorry again..
>
> I am posting the sample data..
>
> my data set is huge.. dimension of my data set is 50000 x 6
> scan.no bird.no date time
> height
> "1" 24 5 "2011-04-29" "21:17:56" 357
> "2" 78 48 "2011-04-29" "21:20:08" 131
> "3" 61 105 "2011-04-29" "21:24:58" 432
> "4" 64 122 "2011-04-29" "21:25:05" 673
> "5" 64 124 "2011-04-30" "21:25:05" 123
> "6" 64 121 "2011-04-30" "21:25:05" 479
> "7" 65 123 "2011-05-03" "21:25:07" 269
> "8" 73 380 "2011-05-03" "21:25:40" 131
> "9" 79 1073 "2011-05-05" "21:25:41" 356
> "10" 82 1093 "2011-05-05" "21:26:24" 378
> "11" 82 1101 "2011-05-05" "21:27:30" 412
>
> I have dates values from april and whole month of may (except some
> days..
> when i was not able to record the data)
>
You are exhibiting discourteous posting behavior by failing to include
context. Nabble is not r-help. Read the Posting Guide.
Here is a worked example using base plotting functions. The data was
read into a dataframe with this structure:
> str(dat)
'data.frame': 11 obs. of 5 variables:
$ scan.no: num 24 78 61 64 64 64 65 73 79 82 ...
$ bird.no: num 5 48 105 122 124 ...
$ date : Date, format: "2011-04-29" "2011-04-29" ...
$ time : chr "21:17:56" "21:20:08" "21:24:58" "21:25:05" ...
$ height : num 357 131 432 673 123 479 269 131 356 378 ...
plot(dat$date, dat$height, xaxt="n")
axis(1, at=dat$date[c(1,11)], # only plot beginning and ending
month names
labels=month.abb[ 1+as.POSIXlt(dat$date[c(1,11)])$mon], # add
1 to index
# the month.abb constant vector
line=2, # shifts these down
lwd=0) # this sppress the extra axis lines
axis(1, at=dat$date, labels=as.POSIXlt(dat$date)$mday) # plot the
days
The aggregate function could be used to calculate daily means and sd's
you mentioned in an earlier posting.
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list