Rcpp can't find sugar functions

Hi, I'm using Rcpp inside the Rstudio.
I wish to use a few Sugar package functions, for example, is_infinite(), is_na() and etc.
I believe sugar.h is included in Rcpp.h
However, the Rstudio does not recognize sugar functions.
I wonder if this is because currently Rstudio can not locate sugar.h function, located in somewhere.

Can anybody help resolving this issue please?


Any way you can reprex this issue for others?

Sorry, I don't understand your reply.
Do you want me to capture my screen?

Any way you might turn this into a reproducible example (reprex) of your issue as a starting point? I'm hoping that'll improve your chances of getting a useful reply.

Thanks for the suggestion.

For example, when I write a simple test code for infinity check

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
double testInfinite() {

double x=log(0.0);

Rcout << x;
Rcout << "is infinite\n";
Rcout << is_infinite(x);

return x;

I get the error message saying
'no matching function for call to 'is_infinite''
However, is_infinite() is in sugar.h according to the web, and sugar.h included in Rcpp.h

Can anybody have any suggestion on this issue?


I just found Rcpp can recognize is_infinite() function only for vector input..
The example is below

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
double testInfinite() {

NumericVector v =
NumericVector::create( 1, NA_REAL, R_NaN, R_PosInf, R_NegInf);
NumericVector x= NumericVector :: create(log(0.0),1/0.0);

LogicalVector l1 = is_na(v);
LogicalVector l2 = is_nan(v);
LogicalVector l3 = is_infinite(v);
LogicalVector l4 = is_infinite(x);

Rcout << l1 << "\n"; // 0 1 1 0 0
Rcout << l2 << "\n"; // 0 0 1 0 0
Rcout << l3 << "\n"; // 0 0 0 1 1
Rcout << l4 << "\n"; // 1 1

return 0.0;

The following page has a good explanation on NaN and Inf in Rcpp