Remove Leading whitespaces from a String in R Language – trimws() Function
trimws() function in R Language is used to trim the leading white spaces. It shrinks an object by removing outermost rows and columns with the same values.
x: Object or character string
Example 1: Remove Leading and Trailing Whitespace
". This is a trim function example"
Here in the above code, we have created a character string and have white spaces in it, So we have used the
trimws() function to remove the white spaces.