[R] Looking for the first observation within the month

2007-05-27 Thread Albert Pang
"2007-04-07" "2007-05-21" Next with D, I then go back and find out the positions of the elements in D within A. And then use the result as an index vector into the vector of observations (which is not shown here) I feel sure I am doing it the stupid way (or the procedural

Re: [R] Looking for the first observation within the month

2007-05-27 Thread Albert Pang
<- function(x, n = 1) head(x, n) > aggregate(z, ave(time(z), as.yearmon(time(z)), FUN = head1), head1) > > > For more on zoo try: > > library(zoo) > vignette("zoo") > > and also read the Help Desk article in R News 4/1 about dates. > > > > On 5/27