[R] Function for trim blanks from a string(s)?
ggrothendieck at gmail.com
Mon Aug 6 21:53:07 CEST 2007
Use trim from:
or trim from gdata or trimWhiteSpace from limma in BioConductor.
RSiteSearch("trim") and help.search("trim") can locate such functions.
s <- c(" abc ", " def ") # vector
m <- cbind(a = s, b = s) # matrix
DF <- as.data.frame(m) # data.frame
DF <- lapply(DF, trim)
On 8/6/07, adiamond <adiamond at csidentity.com> wrote:
> I feel like an idiot posting this because every language I've ever seen has a
> string function that trims blanks off strings (off the front or back or
> both). Ideally, it would process whole data frames/matrices etc but I don't
> even see one that processes a single string. But I've searched and I don't
> even see that. There's a strtrim function but it does something completely
> View this message in context: http://www.nabble.com/Function-for-trim-blanks-from-a-string%28s%29--tf4226133.html#a12022374
> Sent from the R help mailing list archive at Nabble.com.
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help