Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSugar function trimws #679
Comments
Sugar function 'trimws' with unit tests (closes #679)
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upSugar function 'trimws' with unit tests (closes #679)
I put together a sugar function
trimwsto mirrorbase::trimws(added in R 3.2.0). For those not familiar with this, it removes either leading (which = "left"), trailing (which = "right"), or leading and trailing (which = "both") whitespace (defined as any of' ','\t','\r', or'\n') from strings, returningNAonNAinput.In my fork, usage looks like this:
Other features:
whichargument is"both", as inbase::trimwswhichis checked ('b','l', and'r'are valid first letters) to mimic the use ofmatch.argin RCharacterMatrixandStringclassesbaseversion, which uses regex to accomplish thisIf this seems like a worthwhile addition, I can submit a PR shortly.