R-alpha: as.numeric

Peter Dalgaard BSA p.dalgaard@kubism.ku.dk
09 Apr 1997 00:16:43 +0200


Thomas Lumley <thomas@biostat.washington.edu> writes:

> as.numeric() turns a logical matrix into a numeric vector. Shouldn't it 
> stay a matrix?

It *sounds* wrong, but:

S-PLUS : Copyright (c) 1988, 1996 MathSoft, Inc.
S : Copyright AT&T.
Version 3.4 Release 1 for Sun SPARC, SunOS 5.3 : 1996 
Working data will be in .Data 
> cbind(c(T,T),c(F,F))
     [,1] [,2] 
[1,]    T    F
[2,]    T    F
> as.numeric(.Last.value)
[1] 1 1 0 0

In fact, it does the same with numeric matrices.

To convert logical matrix to character matrix in Splus, you could
either add zero or use mode(x)<-"numeric", same thing in R.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-