[R] unclass

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Aug 22 13:06:30 CEST 2003


On Sat, 16 Aug 2003, Spencer Graves wrote:

> I found an answer in "?unclass" and a minor difference between R 1.7.1 
> and S-Plus 6.1.2:

> Now, a trivial comparison between R 1.7.1 and S-Plus 6.1.2:
> 
> ##R 1.7.1
>  > tst <- 2
>  > class(tst)
> [1] "numeric"
>  > Tst <- unclass(tst)
>  > class(Tst)
> [1] "numeric"
>  > mode(Tst)
> [1] "numeric"
> 
> ## Same thing in S-Plus 6.1.2:
>  > tst <- 2
>  > class(tst)
> [1] "integer"
>  > Tst <- unclass(tst)
>  > class(Tst)
> [1] "integer"
>  > mode(Tst)
> [1] "numeric"
> 
> Note that "tst" and "Tst" have class and mode "numeric" in R 1.7.1 but 
> class "integer" and mode "numeric" in S-Plus 6.1.2.

That's because `2' is integer in S-PLUS >=5 and double in R and S-PLUS < 5.
Since you appear not to know that, try it with 2 and 2.0.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list