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? R 1.6.1 on Win98 R.Heberto Ghezzo Ph.D. Meakins-Christie Labs McGill University Montreal - Canada
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)
On Wed, 29 Jan 2003, Heberto Ghezzo wrote:> 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? > > R 1.6.1 on Win98 >It works for me in R 1.6.1 on Windows. > x<-c(1,2,3,4,NA,6,7) > sd(x,na.rm=TRUE) [1] 2.316607 and looking at the code for sd it certainly should. Are you sure you don't have another defintion of sd() lurking? -thomas
Heberto Ghezzo wrote:> 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?> R 1.6.1 on Win98It works with R-1.6.2 (!) which is recent. There was a bug fix regarding NAs and sd() in R-1.6.1, so I guess your version is older than the official release of R-1.6.1. Uwe Ligges> R.Heberto Ghezzo Ph.D. > Meakins-Christie Labs > McGill University > Montreal - Canada > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help