# NOT RUN {
##
## 1. Consider Names = Ruben, Avila and Jose, where "e" and "A" in
## these examples carry an accent. With the default values
## for standardCharacters and replacement, these might be
## converted to something like Rub_n, _vila, and Jos_, with
## different software possibly mangling the names differently.
## (The standard checks for R packages in an English locale
## complains about non-ASCII characters, because they are
## not portable.)
##
nonstdNames <- c('Ra`l', 'Ra`', '`l', 'Torres, Raul',
"Robert C. \\Bobby\\\\", NA, '', ' ',
'$12', '12%')
# }
# NOT RUN {
<!-- %NOTES: -->
# }
# NOT RUN {
<!-- % (1) "\\" gets converted to "\" before testing this. -->
# }
# NOT RUN {
<!-- % (2) "%" indicates a comment; should test this here, -->
# }
# NOT RUN {
<!-- % but I don't see how. -->
# }
# NOT RUN {
# confusion in character sets can create
# names like Names[2]
Name2 <- subNonStandardCharacters(nonstdNames)
str(Name2)
# check
Name2. <- c('Ra_l', 'Ra_', '_l', nonstdNames[4],
'Robert C. "Bobby"', NA, '', ' ',
'$12', '12%')
str(Name2.)
# }
# NOT RUN {
all.equal(Name2, Name2.)
# }
# NOT RUN {
##
## 2. Example from iconv
##
icx <- c("Ekstr\xf8m", "J\xf6reskog",
"bi\xdfchen Z\xfcrcher")
icx2 <- subNonStandardCharacters(icx)
# check
icx. <- c('Ekstrom', 'Joreskog', 'bisschen Zurcher')
# }
# NOT RUN {
all.equal(icx2, icx.)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab