From bates at stat.wisc.edu  Thu Jul  1 20:27:11 2004
From: bates at stat.wisc.edu (Douglas Bates)
Date: Thu Jul  1 20:24:55 2004
Subject: [Rd] AS_NUMERIC and as.numeric - Could someone explain?
In-Reply-To: <0BE5C464-CB84-11D8-806A-000A959F327E@math.uni-augsburg.de>
References: <000701c45eb8$8e001520$82b98283@DH>
	<40E38E8A.5080209@stat.wisc.edu>
	<0BE5C464-CB84-11D8-806A-000A959F327E@math.uni-augsburg.de>
Message-ID: <40E4577F.5010704@stat.wisc.edu>

I knew I should have checked before I mailed that response. :-) I guess 
you are right and I was wrong.

I don't have the opportunity to check bits of R code on the computer 
that I use for email this month.  (I am in northern Canada and my only 
email connection is via a 24 Kb modem connection on a machine running 
Windows ME.  The modem connection is metered so I don't want to download 
the installer for R-1.9.1 for Windows just to be able to check a few 
bits of code.)  I'll try to stay quiet unless I'm sure of the answer.

Simon Urbanek wrote:
> On Jul 1, 2004, at 6:09 AM, Douglas Bates wrote:
> 
>> AS_NUMERIC in C more closely corresponds to as.double() in R
>>
>> All that as.numeric() in R does is assure that the result is of a 
>> numeric mode.  It does not coerce integer variables to doubles.
> 
> 
> Um... are you sure?? For the sake of lots of code I saw I hope you're 
> wrong:
> 
>> Check, for example,
>> str(as.numeric(1:100))
> 
> 
> Yes:
> 
>  > str(as.double(1:10))
>  num [1:10] 1 2 3 4 5 6 7 8 9 10
>  > str(as.numeric(1:10))
>  num [1:10] 1 2 3 4 5 6 7 8 9 10
>  > str(1:10)
>  int [1:10] 1 2 3 4 5 6 7 8 9 10
> 
> And moreover:
> 
>  > as.numeric
> function (x, ...)
> UseMethod("as.double")
> <environment: namespace:base>
> 
> ... admittedly I didn't answer the original question, but I suspect that 
> the problem lies somewhere else ...
> 
> Simon


[Rd] AS_NUMERIC and as.numeric - Could someone explain?
Douglas Bates