[R] as(, "numeric") vs as.numeric()
    Erik Wright 
    eswright at wisc.edu
       
    Mon Feb  1 13:52:24 CET 2016
    
    
  
Hi everyone,
Could someone please explain this R behavior to me:
> typeof(as.numeric(1:10))
[1] "double"
> typeof(as(1:10, "numeric"))
[1] "integer"
I expected "double" in both cases.  In the help for the "as" function it says:
"Methods are pre-defined for coercing any object to one of the basic datatypes. For example, as(x, "numeric") uses the existing as.numeric function."
Thanks,
Erik
    
    
More information about the R-help
mailing list