Friday, December 17, 2010

Trim a string in R

# sub-functions
# Copyright: http://scriptdemo.blogspot.com
mytrim<-function(oristr)
{
     oristr<-sub("^ +","",oristr)
     oristr<-sub(" +$","",oristr)
     # or gsub("(^ +)|( +$)","",oristr)
     return(oristr)
}

No comments:

ShowCalendar