s-news
[Top] [All Lists]

Re: NA problem with aggregate

To: "ONKELINX, Thierry" <Thierry.ONKELINX@inbo.be>, <s-news@lists.biostat.wustl.edu>
Subject: Re: NA problem with aggregate
From: "Petr Pikal" <petr.pikal@precheza.cz>
Date: Fri, 25 Nov 2005 15:00:15 +0100
In-reply-to: <2E9C414912813E4EB981326983E0A10401255E49@inexch.instnat.be.grp>
Hi

Did not you by chance redefine sum function? I can not 
reproduce this behaviour although I tested it on R only.

Cheers
Petr
 



On 25 Nov 2005 at 13:36, ONKELINX, Thierry wrote:

Subject:                [S] NA problem with aggregate
Date sent:              Fri, 25 Nov 2005 13:36:07 +0100
From:                   "ONKELINX, Thierry" <Thierry.ONKELINX@inbo.be>
To:                     <s-news@lists.biostat.wustl.edu>

> Dear listers,
> 
> 
> 
> I'm working with a data frame with 6 columns. The first column
> indicates the year (ranging from 1993 until present) and the other
> ones the measurements at different locations. For each year there are
> several measurements and some of them are missing (NA). I need to sum
> the measurements in each column by year. The aggregate function should
> do the trick but the NA's our troubling me.
> 
> 
> 
> The command:
> 
> aggregate(CiVi22), by = list(CiVi22$Year), FUN = sum, na.rm = T)
> 
> 
> 
> The output:
> 
>      Group.1      X11 X14 X15 X16 X21 
> 
> 1993    1993       NA  NA  NA  NA  NA
> 
> 1994    1994 3745.594  NA  NA  NA  NA
> 
> 1995    1995       NA  NA  NA  NA  NA
> 
> 1996    1996       NA  NA  NA  NA  NA
> 
> 1997    1997       NA  NA  NA  NA  NA
> 
> 1998    1998       NA  NA  NA  NA  NA
> 
> 1999    1999       NA  NA  NA  NA  NA
> 
> 2000    2000       NA  NA  NA  NA  NA
> 
> 2001    2001       NA  NA  NA  NA  NA
> 
> 2002    2002       NA  NA  NA  NA  NA
> 
> 2003    2003       NA  NA  NA  NA  NA
> 
> 2004    2004       NA  NA  NA  NA  NA
> 
> 
> 
> This output is correct for the same command but without the na.rm
> parameter (or with na.rm = F). Including na.rm = T doesn't seem to
> effect the sum function although it should. Any ideas about what's
> going wrong?
> 
> 
> 
> Thank you in advance.
> 
> 
> 
> Thierry
> 
> --------------------------------------------------------
> ir. Thierry Onkelinx
> Instituut voor Bosbouw en Wildbeheer (Institute for Forestry and Game
> Management) Team Biometrie, methodologie en kwaliteitszorg Gaverstraat
> 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 fax. + 32 54/436
> 160 Thierry.Onkelinx@inbo.be http://ibw.inbo.be
> 
> 
> 
> 

Petr Pikal
petr.pikal@precheza.cz


<Prev in Thread] Current Thread [Next in Thread>