aggregate can also be used:

   aggregate(d, list(d = d), length) # output is data frame

or using zoo:

   library(zoo)
   aggregate(zoo(as.vector(d)), d, length) # output is a zoo object

If what you actually have is a zoo object such as this one:

   z <- zoo(1:10, d)

then the last statement could be written

   aggregate(z, time(z), length)

Note that z has non-unique times so strictly speaking z is an illegal
zoo object.although at least currently such objects can be constructed
by zoo or read.zoo and operated on by aggregate.zoo though most
other zoo operations will not accept them.

On 11/2/06, antonio rodriguez <[EMAIL PROTECTED]> wrote:
> Brandt, T. (Tobias) escribió:
> >
> > I think the following does what you want:
> >
> > > (d <- structure(c(6586, 6586, 6589, 6593, 6593, 6593, 6598, 6598,
> > 6598, 6598), class = "Date"))
> >  [1] "1988-01-13" "1988-01-13" "1988-01-16" "1988-01-20" "1988-01-20"
> > "1988-01-20" "1988-01-25"
> >  [8] "1988-01-25" "1988-01-25" "1988-01-25"
> > > (td <- table(d))
> >
> Dear Tobias,
>
> Yes it does!! And it's enough with the last sentence: td<-table(d)
>
> since the following outputs (don't know why, probably because I'm
> working with a zoo object?):
>
> names(td) <- as.Date(as.numeric(names(td)))  # to make the names more
> readable
> Warning message:
> NAs introducidos por coerción
>  > print(td)
> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
> <NA> <NA>
>   2    1    3    6    5    4    3    4    3    1    1    1   10    1
> 1    2
>
> Thanks a lot!
>
> Antonio
>
>
> > d
> > 6586 6589 6593 6598
> >    2    1    3    4
> > > names(td) <- as.Date(as.numeric(names(td)))  # to make the names
> > more readable
> > > print(td)
> > 1988-01-13 1988-01-16 1988-01-20 1988-01-25
> >          2          1          3          4
> > >
> >
> > HTH,
> >
> > Tobias
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to