trimws_ | R Documentation |
To remove leading/trailing and duplicated (symbols that look like) white spaces.
More aggressive than function trimws.
trimws_(x)
x |
an object with typeof being character |
Function trimws_ is more aggressive than trimws, that it removes
duplicated white spaces
symbols that look like white space, such as \u00a0
(no-break space)
Function trimws_ returns an object of typeof character.
gsub keeps attributes
(x = c(A = ' a b ', b = 'a . s', ' a , b ; ', '\u00a0 ab '))
base::trimws(x)
# raster::trim(x) # do not want to 'Suggests'
trimws_(x)
(xm = matrix(x, nrow = 2L))
trimws_(xm)
#library(microbenchmark)
#microbenchmark(trimws(x), trimws_(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.