[R] Weird Behavior of mean

Ivo Welch |vo@we|ch @end|ng |rom gm@||@com
Fri Dec 13 01:23:01 CET 2024


Is the following a strange behavior for `mean` vs. `sd` ?

```
$ R --vanilla. ## 4.4.2
> x=c(NA,1,2,3)
> c( mean(x,na.rm=T), sd(x,na.rm=T) )
[1] 2 1
> T=20   ## bad idea for a parameter.  T is also used for TRUE
> c( mean(x,na.rm=T), sd(x,na.rm=T) )
[1] NA  1
>
```

This one was a baffler for me to track down for a few hours...



More information about the R-help mailing list