trim white spaces in R code example Example: remove all trailing whitspaces R x = " string " trimws(x) x # [1] "string"