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.
- Case conversion of a String in R Language - toupper(), tolower(), casefold() and cartr() Function
- Add Leading Zeros to the Elements of a Vector in R Programming - Using paste0() and sprintf() Function
- Rounding off values in R Language - round() Function
- Converting a List to Vector in R Language - unlist() Function
- Convert elements of a Vector to Strings in R Language - toString() Function
- Calculate Square root of a number in R Language - sqrt() Function
- Getting Multiplication of the Objects passed as Arguments in R Language - prod() Function
- Modify values of a Data Frame in R Language - transform() Function
- Changing row and column values of a Matrix in R Language - sweep() function
- Combine Vectors, Matrix or Data Frames by Columns in R Language - cbind() Function
- Combine Vectors, Matrix or Data Frames by Rows in R Language - rbind() Function
- Get the natural logarithm of the beta value of Non-Negative numeric vectors in R Language - lbeta() Function
- Difference Between C Language and LISP Language
- Generate a Vector of specified length with each element as a unique color on RB scale in RGB spectrum in R Language - cm.colors() Function
- Generate a Vector of specified length with each element as a unique color on RGB scale in R Language - topo.colors() Function
- Generate a Vector of specified length with each element as a unique color on RG scale in RGB spectrum in R Language - terrain.colors() Function
- Remove Objects from Memory in R Programming - rm() Function
- Remove names or dimnames from an Object in R Programming - unname() Function
- Remove Duplicate Elements from an Object in R Programming - unique() Function
- Remove unnecessary values from an Object in R Programming - na.omit() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.