Displaying 1 result from an estimated 1 matches for "boub".
Did you mean:
bob
2009 Jun 18
2
Argument as.integer(NA) to a function C
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 :
--- C code ---
void essai(int *t){
Rprintf("\nT0=%i T1=%i T2=%i T3=%i",t[0],t[1],t[2],t[3]);
}
--- R ---
boub <- c(1,2,3,4)
.C("pour",as.integer(boub),NAOK=TRUE)
# 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 c...