[Rd] Argument as.integer(NA) to a function C

From: Christophe Genolini <cgenolin_at_u-paris10.fr>
Date: Thu, 18 Jun 2009 15:57:24 +0200


Hi the list,
I am writing a R function that call a C function. The C function needs integers but I do not manage to give a NA integer as argument :

# T0=1 T1=2 T2=3 T3=4[[1]]
# [1] 1 2 3 4

boub <- c(1,2,NA,4)
.C("essai",as.integer(boub),NAOK=TRUE)

# T0=1 T1=2 T2=-2147483648 T3=4[[1]]
# [1] 1 2 NA 4
--- ---

In the second example, T2=-2147483648 and not NA.

I check the "writing R extension", there is a part that explain that the test of NA is not the same between double and integer (NA_INTEGER, ISNA), but I did not find explanation on passing NA argument as integer.

Any idea of what is wrong in my code?

Christophe



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 18 Jun 2009 - 14:02:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 18 Jun 2009 - 17:36:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive