DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
A simple function to trim whitespace from the beginning and end of a string, which you could then use to more simply split a string into a vector, uses gsub:
> trim.ws <- function(text) + gsub("^[[:blank:]]*", "", gsub("[[:blank:]]*$", "", text)) > s <- " a b c " > strsplit(trim.ws(s), " +") [1] "a" "b" "c" |