[R] Plotting Questions (was: Results of applying na.omit on zoo object)

Gabor Grothendieck ggrothendieck at gmail.com
Tue Sep 20 02:40:00 CEST 2011


On Mon, Sep 19, 2011 at 8:34 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> On Mon, 19 Sep 2011, Gabor Grothendieck wrote:
>
>> names(z) gives the column names of zoo object z.
>
>> # get a list of date ranges
>> lapply(1:ncol(z), function(i) range(time(na.omit(z[, i]))))
>

If z has column names (but do not use this if it does not) then the
following improvement will display them in the output:

> sapply(names(z), function(nm) range(time(na.omit(z[, nm]))), simplify = FALSE)
$a
[1] "2011-09-21" "2011-09-23"

$b
[1] "2011-09-22" "2011-09-24"



-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-help mailing list