##
## 1. Example
##
tstSNSN <- c('Raul', 'Ra`l', 'Torres,Raul',
'Torres, Ra`l', "Robert C. \\Bobby\\\\",
'Ed \n --Vacancy', '', ' ')
# confusion in character sets can create
# names like Names[2]
##
## 2. subNonStandardNames(vector)
##
SNS2 <- subNonStandardNames(tstSNSN)
SNS2
# check
SNS2. <- c('Raul', 'Raul', 'Torres,Raul', 'Torres, Raul',
'Robert C. "Bobby"', 'Ed', '', '')
attr(SNS2., 'secondLine') <- c(rep(NA, 5), ' --Vacancy',
NA, NA)
stopifnot(
all.equal(SNS2, SNS2.)
)
##
## 3. subNonStandardNames(matrix)
##
tstmat <- parseName(tstSNSN, surnameFirst=TRUE)
submat <- subNonStandardNames(tstmat)
# check
SNSmat <- parseName(SNS2., surnameFirst=TRUE)
stopifnot(
all.equal(submat, SNSmat)
)
##
## 4. subNonStandardNames(data.frame)
##
tstdf <- as.data.frame(tstmat)
subdf <- subNonStandardNames(tstdf)
# check
SNSdf <- as.data.frame(SNSmat, stringsAsFactors=FALSE)
stopifnot(
all.equal(subdf, SNSdf)
)
##
## 5. namesNotFound
##
noSub <- subNonStandardNames('xx_x')
# check
noSub. <- 'xx_x'
attr(noSub., 'namesNotFound') <- 'xx_x'
stopifnot(
all.equal(noSub, noSub.)
)
Run the code above in your browser using DataLab