From berwin@maths.uwa.edu.au  Mon May 22 03:39:33 2000
From: berwin@maths.uwa.edu.au (berwin@maths.uwa.edu.au)
Date: Mon, 22 May 2000 04:39:33 +0200 (MET DST)
Subject: [Rd] Inconsistencies (PR#550)
Message-ID: <200005220239.EAA14342@pubhealth.ku.dk>

Dear all,

I was playing around with some C-code that I dynamically linked to R
and noticed the following inconsistency:

> dat <- matrix(1,3,3)
> is.double(dat)
[1] TRUE
> is.integer(dat)
[1] FALSE
> dat <- matrix(1:9,3,3)
> is.double(dat)
[1] FALSE
> is.integer(dat)
[1] TRUE

How did I find out?  I passed `dat' to a double * in the C-code and
printed out the matrix from C.  But in the .C() call I just passed
down `dat' and forgot to coerce to double via `as.double(dat)'.  Of
course the print out from the C routine was garbage, but since I used
        dat <- matrix(1,3,3)
first, I was confused.  Note that R says that `dat' is.double!  But it
seems to pass dat to C as an integer matrix nevertheless!  Using the
second matrix it became clear to me why I saw garbage being printed
out from the C-routine.  My question is now why does the first
`is.double(dat)' returns `TRUE'?

Cheers,

        Berwin


--please do not edit the information below--

Version:
 platform = i686-unknown-linux
 arch = i686
 os = linux
 system = i686, linux
 status = 
 major = 1
 minor = 0.1
 year = 2000
 month = April
 day = 14
 language = R

Search Path:
 .GlobalEnv, Autoloads, package:base

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Inconsistencies (PR#550)
berwin@maths.uwa.edu.au