[R] what's this character?

Shi, Tao shidaxia at yahoo.com
Thu Nov 29 01:44:59 CET 2012


Hi list,

I've encounter this problem (see below).  I know it's particularly R-related and it's easy to get by but it still bothers me a lot.  


It looks the last character of "N.C. " is a space to me, but it's clearly not.  Can someone tell me a way to figure out what character is in the last position.

Thanks!

Tao



> levels(dat$flag)[3]
[1] "N.C. "
> levels(dat$flag)[3]=="N.C. "
[1] FALSE
> substr(levels(dat$flag)[3],5,5)
[1] " "
> substr(levels(dat$flag)[3],5,5)==" "
[1] FALSE
> "N.C. "=="N.C. "   ## NOTE: this last one can't be reproduced after copy-n-paste
[1] FALSE



More information about the R-help mailing list