[R] Basic matematical functions with NAs

roger bos roger.bos at gmail.com
Tue May 24 16:36:25 CEST 2005

```Simple, all those functions, such as sum(), colSums(), colMeans(),
etc. have an argument called na.rm which you can set to TRUE to remove
NAs.

so try something like sum(X, na.rm=TRUE)

HTH,

Roger

On 5/24/05, Paulo Brando <pmbrando at ipam.org.br> wrote:
> Dear All,
>
> I've tried to sum columns -- different species of flowers, fruits plus twigs -- with NAs to get litterfall/trap, and then after use litterfall to calculate production (litterfall (grams)/ hectare/ day. But R 'sees' litterfall/trap as a string.
>
> My question: How to use basic mathematical functions to deal with NAs in data management.
>
> Example (as you can note I have many missing values -- no fruit  fell in the trap.
>
>
>      area ponto date pseco psaco pliquido florg1 flor1 florg2 flor2 florg3 flor3 frutog1 fruto1 frutog2 fruto2 frutog3 fruto3 frutog4 fruto4 frutog5 fruto5 frutog6 fruto6 frutog7 fruto7 frutog8 fruto8 twigs
>      A A 1 38233 17.7 1.6 7.1 0.266 1
>      A AA 1 38233 12.5 8.7 3.8
>      A AB 1 38233 13.9 1.7 3.2       0.421 3
>      A B 1 38233 12.1 1.6 1.5       0.248 2 0.435 7 0.16 1
>      A BORDA 1 38233
>      A C 1 38233 15.6 1.7 4.9       0.374 2 0.298 3 0.231 1
>      A F 1 38233 14 1.5 3.5 0.366 45     0.153 1 0.15 1
>
>
>
> Paulo Brando
> Inst. de Pesquisa Ambiental da Amazônia (IPAM)
> Rua Rui Barbosa,136.
> 68.005.080 Santarém, PA, Brazil.
> Fone/Fax ++ 55 93 522 5538
> www.ipam.org.br
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help