[R] substrings

Vladimir Eremeev wl2776 at gmail.com
Thu Aug 9 11:26:59 CEST 2007


Is this what you want?

> a<-c("a b c","1 2 3","q - 5")
> a
[1] "a b c" "1 2 3" "q - 5"
> sapply(strsplit(a,"[[:blank:]]"),function(x)x[1])
[1] "a" "1" "q"


Edna Bell wrote:
> 
> I have a set of character results.  If one of the characters is a
> blank space, followed by other characters, I want to end at the blank
> space.
> 
> I tried strsplit, but it picks up again after the blank.
> 
> Any help would be much appreciated.
> 


-- 
View this message in context: http://www.nabble.com/substrings-tf4241506.html#a12069209
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list