From bolker at ufl.edu  Sat Jun  7 01:48:23 2008
From: bolker at ufl.edu (Ben Bolker)
Date: Fri, 6 Jun 2008 23:48:23 +0000 (UTC)
Subject: [Rd] sd function (PR#11586)
References: <20080605131003.4C2F6282EFF7@mail.pubhealth.ku.dk>
Message-ID: <loom.20080606T233028-608@post.gmane.org>

 <rfolgueira <at> yahoo.com> writes:

> 
> Full_Name: Ram?n Folgueira Roque
> Version: 2.7.0
> OS: Windows
> Submission from: (NULL) (200.11.210.98)
> 
> The sd function doesn`t give the same results than older version, when it?s
> applied to a data frame object and the object contains some character data.
> 
> Ex:
> datos=data.frame( )
> fix(datos)
>           Grupo Vel 
>           A     10.1       
>           A     9.8            
>           B     10             
>           B     10             
>           A     9.9           
>           A     10.1          
>           B     NA           
>           A     10            
> 
> sd(datos,na.rm=T)
> 
> ___________________

  This is almost certainly a consequence of the following
change in R 2.7.0:

    o	co[rv](use = "complete.obs") now always gives an error if there
	are no complete cases: they used to give NA if
	method = "pearson" but an error for the other two methods.
	(Note that this is pretty arbitrary, but zero-length vectors
	always give an error so it is at least consistent.)
What's happening is that R tries to run sd() on each column.
The first column is coerced to a character, then var() says
there are no non-missing observations.

  This has been discussed (and complained about) previously.
(I'd like to add my vote for reversion of this behavior, because
it screws up one of the examples in my soon-to-be-published
book ... argh.)

  cheers
    Ben Bolker



[Rd] sd function (PR#11586)
Ben Bolker