[R] Dealing with NAs in C

chris90nz chrisstevensphotography at ihug.co.nz
Sun Feb 26 01:41:09 CET 2012


Hi.
I am currently converting a lot of R code to C in order to make it more
efficient. A lot of the data involves NAs. As the data is mainly integers >
0, I am just setting all NAs to 0 then sending it to the C code then
resetting them to NAs again after the C program is done, to be compatible
with the rest of the R code.

Is there a more efficient way to deal with NAs in C? I have used NAOK=true
and sent them through using tobs=as.integer(tobs) for example, but when C
looks at a NA it crashes. 

I am looking for the most efficient way to deal with NAs when they need to
be sent to a C function.

Any info here would be greatly appreciated!

Cheers,

Chris

--
View this message in context: http://r.789695.n4.nabble.com/Dealing-with-NAs-in-C-tp4421377p4421377.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list