switch isnan() to ISNAN() to avoid a conflict between R's header and C++11