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.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to