[R] subsetting, aggregating and zoo

antonio rodriguez antonio.raju at gmail.com
Thu Nov 2 09:30:47 CET 2006


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
>



More information about the R-help mailing list