t <- "TheWeatherIsVeryNice" How do I extract the upper case letters? - TWIVN Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html Sent from the R help mailing list archive at Nabble.com.
How do you want your output? If you want a character vector of lowercase letters, just use gsub("[^::A-Z::]","", t) to substitute "" for all non-uppercase characters. strsplit() can lead you to a vector of the single-letter upper case letters. Best, Michael On Wed, Jun 27, 2012 at 2:15 PM, mdvaan <mathijsdevaan at gmail.com> wrote:> t <- "TheWeatherIsVeryNice" > > How do I extract the upper case letters? - TWIVN > > Thanks! > > -- > View this message in context: http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
Hello, Try the following. txt <- "TheWeatherIsVeryNice" Up <- strsplit(txt, "[[:lower:]]*") Up[Up != ""] Hope this helps, Rui Barradas Em 27-06-2012 20:15, mdvaan escreveu:> t <- "TheWeatherIsVeryNice" > > How do I extract the upper case letters? - TWIVN > > Thanks! > > -- > View this message in context: http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >
----- Forwarded Message ----- From: arun <smartpink111 at yahoo.com> To: mdvaan <mathijsdevaan at gmail.com> Cc: R help <r-help at r-project.org> Sent: Thursday, June 28, 2012 1:44 AM Subject: Re: [R] Extract upper case letters Hi, Try this: t <- "TheWeatherIsVeryNice" ?t1<-gsub("[:A-Z:]","",t) ?t1 [1] "heeatherseryice" t2<-gsub("[:a-z:]","",t)> t2[1] "TWIVN" A.K. ----- Original Message ----- From: mdvaan <mathijsdevaan at gmail.com> To: r-help at r-project.org Cc: Sent: Wednesday, June 27, 2012 3:15 PM Subject: [R] Extract upper case letters t <- "TheWeatherIsVeryNice" How do I extract the upper case letters? - TWIVN Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at 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.
Thanks, all solutions worked like a charm. Math arun kirshna wrote> > ----- Forwarded Message ----- > From: arun <smartpink111@> > To: mdvaan <mathijsdevaan@> > Cc: R help <r-help@> > Sent: Thursday, June 28, 2012 1:44 AM > Subject: Re: [R] Extract upper case letters > > Hi, > > Try this: > t <- "TheWeatherIsVeryNice" > ?t1<-gsub("[:A-Z:]","",t) > ?t1 > [1] "heeatherseryice" > > > t2<-gsub("[:a-z:]","",t) >> t2 > [1] "TWIVN" > > > A.K. > > > > > ----- Original Message ----- > From: mdvaan <mathijsdevaan@> > To: r-help@ > Cc: > Sent: Wednesday, June 27, 2012 3:15 PM > Subject: [R] Extract upper case letters > > t <- "TheWeatherIsVeryNice" > > How do I extract the upper case letters? - TWIVN > > Thanks! > > -- > View this message in context: > http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@ 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. > > ______________________________________________ > R-help@ 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. >-- View this message in context: http://r.789695.n4.nabble.com/Extract-upper-case-letters-tp4634664p4634802.html Sent from the R help mailing list archive at Nabble.com.