How can I trim leading and trailing white space?

后端 未结 13 1495
北海茫月
北海茫月 2020-11-22 03:53

I am having some troubles with leading and trailing white space in a data.frame.

For example, I like to take a look at a specific row in a data.fra

13条回答
  •  粉色の甜心
    2020-11-22 04:03

    Removing leading and trailing blanks might be achieved through the trim() function from the gdata package as well:

    require(gdata)
    example(trim)
    

    Usage example:

    > trim("   Remove leading and trailing blanks    ")
    [1] "Remove leading and trailing blanks"
    

    I'd prefer to add the answer as comment to user56's, but I am yet unable so writing as an independent answer.

提交回复
热议问题