<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hi Tim,</div><div><br></div><div><blockquote type="cite"><div dir="ltr">def = "bool is_na_character_vector(CharacterVector x) { return CharacterVector::is_na(x); }"</div></blockquote><br></div><div>x is a CharacterVector, so you need to check is_na on each element separately. Try:</div><div><br></div><div>def = "bool is_first_character_na(CharacterVector x) {return CharacterVector::is_na(x[0]);}"</div><div><br></div><div>and see the Rcpp gallery for more examples:</div><div><a href="http://gallery.rcpp.org/articles/working-with-missing-values/">http://gallery.rcpp.org/articles/working-with-missing-values/</a></div><div><br></div>Best,<br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Hao Ye</div><div><a href="mailto:hye@ucsd.edu">hye@ucsd.edu</a></div></div></span></span>
</div>
<br><div><div>On Feb 10, 2015, at 1:50 PM, Tim Keitt <<a href="mailto:tkeitt@utexas.edu">tkeitt@utexas.edu</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>library(Rcpp)</div><div>def = "bool is_na_character_vector(CharacterVector x) { return CharacterVector::is_na(x); }"</div><div>f = cppFunction(def)</div><div>print(f(as.character(NA))) # FALSE</div><div><br></div><div>What am I missing?</div><div><br></div><div>THK</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div></div>
</div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></body></html>