[Rcpp-devel] CharacterVector::is_na

Tim Keitt tkeitt at utexas.edu
Tue Feb 10 23:25:55 CET 2015


On Tue, Feb 10, 2015 at 4:05 PM, Hao Ye <hye at ucsd.edu> wrote:

> Hi Tim,
>
> def = "bool is_na_character_vector(CharacterVector x) { return
> CharacterVector::is_na(x); }"
>
>
> x is a CharacterVector, so you need to check is_na on each element
> separately. Try:
>
> def = "bool is_first_character_na(CharacterVector x) {return
> CharacterVector::is_na(x[0]);}"
>
> and see the Rcpp gallery for more examples:
> http://gallery.rcpp.org/articles/working-with-missing-values/
>

Argh. Yes. I knew that was the problem, but tested it with x[1] not x[0] --
too much switching back and forth between R and C++....

Thanks.

THK


>
> Best,
> --
> Hao Ye
> hye at ucsd.edu
>
> On Feb 10, 2015, at 1:50 PM, Tim Keitt <tkeitt at utexas.edu> wrote:
>
> library(Rcpp)
> def = "bool is_na_character_vector(CharacterVector x) { return
> CharacterVector::is_na(x); }"
> f = cppFunction(def)
> print(f(as.character(NA))) # FALSE
>
> What am I missing?
>
> THK
>
> --
> http://www.keittlab.org/
>  _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
http://www.keittlab.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20150210/5427f102/attachment.html>


More information about the Rcpp-devel mailing list