Description Usage Arguments Details Value Examples
could do this with regular expression, but slow, and this function is called frequently. My only use case works with removal of all space character whitespace, and I don't expect <TAB>. This uses non-unicode aware matching for speed. This can be changed by setting useBytes to FALSE.
1 |
x |
is a character vector to strip |
pattern |
is the non-regex of the character to strip, default " " |
useBytes |
logical scalar. Unlike gsub, this will default to TRUE here, therefore breaking unicode. |
gsub
is probably quicker than stringr
/stringi
. For
comorbidity processing, this package prefers the faster base
functions, whereas stringr
is used for tasks which are not time
critical, e.g. parsing source data to be included in the distributed
icd
package.
character vector
1 2 3 4 5 6 7 8 9 10 11 12 | ## Not run:
requireNamespace("microbenchmark")
requireNamespace("stringr")
x <- random_string(25000)
microbenchmark::microbenchmark(
gsub(x = x, pattern = "A", replacement = "", fixed = TRUE, useBytes = TRUE),
gsub(x = x, pattern = "A", replacement = "", fixed = TRUE, useBytes = TRUE, perl = TRUE),
gsub(x = x, pattern = "A", replacement = ""),
stringr::str_replace_all(x, "A", "")
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.