r - Using non-ASCII characters inside functions for packages -
i'm trying write function equivalent scales::dollar
adds pound (£) symbol beginning of figure. since scales code robust, i've used framework , replaced $ £.
a stripped-down function example:
pounds<-function(x) paste0("£",x)
when run check following:
found following file non-ascii characters: pounds.r portable packages must use ascii characters in r code, except perhaps in comments. use \uxxxx escapes other characters.
looking through writing r extensions guide doesn't give lot of (imo) on how resolve issue. mentions \uxxxx , says refers unicode characters.
looking unicode characters yields me code £
guidance can find \uxxxx
minimal , relates java on w3schools.
my question thus:
how implement usage of non-unicode characters in r functions using \uxxxx escapes , how usage affect display of such characters after function has been used?
for \uxxxx escapes, need know hexadecimal number of character. can determine using chartoraw
:
sprintf("%x", as.integer(chartoraw("£"))) [1] "a3"
now can use specify non-ascii character. both \u00a3
, £
represent same character.
Comments
Post a Comment