[R] na.rm in sd()

Douglas Bates bates at stat.wisc.edu
Wed Jan 29 19:46:02 CET 2003


Heberto Ghezzo <heberto.ghezzo at mcgill.ca> writes:

> Hello, I think this qualify as a bug
>  > x<-c(1,2,3,4,NA,6,7)
>  > mean(x)
> [1] NA
>  > mean(x,na.rm=T)
> [1] 3.833333
>  > sd(x)
> Error in var(as.vector(x)) : missing observations in cov/cor
>  > sd(x,na.rm=T)
> Error in sd(x, na.rm = T) : unused argument(s) (na.rm ...)
>  > var(x)
> Error in var(x) : missing observations in cov/cor
>  > var(x,na.rm=T)
> [1] 5.366667
>  >
> why sd() does not recognize the na.rm=T parameter, while var does?

It does, in R-1.6.2

> args(sd)
function (x, na.rm = FALSE)




More information about the R-help mailing list