On Sat, 15 Sep 2007, kevinchang wrote: > > Hi everyone, > > I am wondering if there is any built-in funcion that can determine whether > words in a character vector start with a captial letter or not. Help, > please. Thanks.
Yes. But your query is not precise. See the posting guide and provide commented, minimal, self-contained, reproducible code (as is requested) to be sure the answers you get address the question you really want answered. I see several possiblilities. In this vector: my.charvec<- c( "Abc", "abc Abc", "abc aBc" ) You wish to match element 1 only or 1 and 2 only and perhaps report where in each element the last match was found. res <- regexpr( "\\<[[:upper:]].*" , my.charvec ) should get you started. Examples: which( res == 1 ) # first case which( res != -1 ) # second case See ?regexpr Also, ?strsplit which I think would be needed to recover the locations of each of several capitalized words in a single element. e.g. "abc Def Ghi" Chuck > -- > View this message in context: > http://www.nabble.com/starting-with-a-capital-letter-tf4447302.html#a12689105 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org 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. > Charles C. Berry (858) 534-2098 Dept of Family/Preventive Medicine E mailto:[EMAIL PROTECTED] UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 ______________________________________________ R-help@r-project.org 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.