[R] Results of applying na.omit on zoo object
ggrothendieck at gmail.com
Tue Sep 20 00:06:49 CEST 2011
On Mon, Sep 19, 2011 at 5:33 PM, Marc Schwartz <marc_schwartz at me.com> wrote:
> On Sep 19, 2011, at 4:00 PM, Rich Shepard wrote:
>> On Mon, 19 Sep 2011, Marc Schwartz wrote:
>>>> Is there a way to omit only those rows where all columns contain 'NA'?
>>> You can look at ?complete.cases for one approach, presuming that it will
>>> work on zoo objects.
>> Do I even need to worry about these NAs? Thanks to Gabor I have a data
>> frame with 296 stream/parameter sets. Each set begins and ends on a
>> different date (used as the zoo index).
>> What I want to do initially is plot the time series for each
>> stream/parameter to see what each has to tell us. In this case, if there are
>> years of NAs prior to the fist measurement for that stream/parameter pair,
>> will this affect anything.
>> On a related note, I'm reading the zoo help pages and vignettes but do not
>> see the syntax for specifying which stream/parameter pair I want to plot.
>> What do I read to learn how to do this?
> Hi Rich,
> Let me start by acknowledging that I have little practical experience in time series analyses, much less proficiency with the zoo package. I just don't come across them much in clinical trials/studies, at least the ones that I have been involved with over the past 25+ years.
> I do know from prior posts on the matter, that the zoo package seems to have some of its own approaches to dealing with dates, as compared to base R. So you may need to be clear on the differentiation in code/functions required to use some of the package functionality.
This is not at all the case. zoo relies on external facilities to
handle index classes and not its own facilities.
In some cases zoo extends base facilities or adds new classes to give
additional possibilities but when this is done the base functionality
is always extended and never changed. There are no exceptions to this
In fact, the only time zoo functions or methods have any understanding
of index classes is when interfacing to the outside world since such
interfacing implies knowledge of how the external objects work.
For accurate information on the design of zoo read
and the other four vignettes and as well as the help files in the zoo package.
Regarding plotting plotting in zoo is similar to in R so NAs are
ignored in plots. Thus leading and trailing NAs do not result in
anything on the plot. To plot a zoo object try:
plot(z) # multiple panels
plot(z, screen = 1) # all columns on 1 panel
xyplot also accepts the screen= argument and more info is in ?plot.zoo
and ?xyplot.zoo Like most zoo functions they tend to work like core
R functions so if you understand those then the working with the zoo
ones come natural.
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
email: ggrothendieck at gmail.com
More information about the R-help