#how do I break these up into first two letters (RM), number, and then the last part #is there an easily accessible regex tutorial on the internet? v = (structure(1:122, .Label = c("RM215Temp", "RM215SpCond", "RM215DO.Conc", "RM215Depth", "RM215pH", "RM215ORP", "RM215Turbidity.", "RM215Battery", "RM215DO.", "SCTemp", "SCSpCond", "SCDO.Conc", "SCDepth", "SCpH", "SCORP", "SCTurbidity.", "SCBattery", "SCDO.", "RM202Temp", "RM202SpCond", "RM202DO.Conc", "RM202Depth", "RM202pH", "RM202ORP", "RM202Turbidity", "RM202Battery", "RM202DO.", "RM198Temp", "RM198SpCond", "RM198DO.Conc", "RM198Depth", "RM198pH", "RM198ORP", "RM198Turbidity.", "RM198Battery", "RM198DO.", "HCTemp", "HCSpCond", "HCDO.Conc", "HCDepth", "HCpH", "HCORP", "HCTurbidity.", "HCBattery", "HCDO.", "RM190Temp", "RM190SpCond", "RM190DO.Conc", "RM190Depth", "RM190pH", "RM190ORP", "RM190Turbidity.", "RM190Battery", "RM190DO.", "BCTemp", "BCSpCond", "BCDO.Conc", "BCDepth", "BCpH", "BCORP", "BCTurbidity.", "BCBattery", "BCDO.", "RM185Temp", "RM185SpCond", "RM185DO.Conc", "RM185Depth", "RM185pH", "RM185ORP", "RM185Turbidity.", "RM185Battery", "RM185DO.", "RM179Temp", "RM179SpCond", "RM179DO.Conc", "RM179Depth", "RM179pH", "RM179ORP", "RM179Turbidity.", "RM179Battery", "RM179DO.", "RM148Temp", "RM148SpCond", "RM148DO.Conc", "RM148Depth", "RM148pH", "RM148ORP", "RM148Turbidity.", "RM148Battery", "RM148DO.", "RM119Temp", "RM119SpCond", "RM119DO.Conc", "RM119Depth", "RM119pH", "RM119ORP", "RM119Turbidity.", "RM119Battery", "RM119DO.", "RM61Temp", "RM61SpCond", "RM61DO.Conc", "RM61Depth", "RM61pH", "RM61ORP", "RM61Turbidity.", "RM61Battery", "RM61DO.", "NSBL.Dflow", "RM148flow", "RM119flow", "RM61flow", "RM190heat", "RM185heat", "RM148heat", "RM119heat", "RM61heat", "RM190DOmass", "RM185DOmass", "RM148DOmass", "RM119DOmass", "RM61DOmass"), class = "factor")) thanks -- Stephen Sefick Research Scientist Southeastern Natural Sciences Academy Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
stephen sefick <ssefick <at> gmail.com> writes:> > #how do I break these up into first two letters (RM), number, and then > the last part > #is there an easily accessible regex tutorial on the internet?For regular expressions, the perl man pages at <http://perldoc.perl.org/ perlre.html> are quite good and present the essentials in condensed form, but still very useful. (Some constructs may not work outside of Perl.) A more elaborate tutorial is to be found at Regular-Expressions.info, i.e. <http://www.regular-expressions.info/>. Of course, there are many, many more, see the Open Directory for one long list. And each programming language has its own page on regular expressions. At the Regular Expression Library <http://regexlib.com> you can search for and copy regular expressions, for example there are 20 patterns returned when searching for regular expressions on 'floats'. Hans Werner Borchers> v = (structure(1:122, ... > > thanks >
You can do this one even more easily without regular expressions like this: substring(v, 1, 2) substring(v, 3) or with regexps: sub("(..).*", "\\1", v) sub("..(.*)", "\\1", v) or in one line using strapply in the gsubfn package: library(gsubfn) # see http://gsubfn.googlecode.com out <- strapply(as.character(v), "(..)(.*)", c, simplify = rbind) On Tue, Nov 11, 2008 at 2:33 PM, stephen sefick <ssefick at gmail.com> wrote:> #how do I break these up into first two letters (RM), number, and then > the last part > #is there an easily accessible regex tutorial on the internet? > > v = (structure(1:122, .Label = c("RM215Temp", "RM215SpCond", "RM215DO.Conc", > "RM215Depth", "RM215pH", "RM215ORP", "RM215Turbidity.", "RM215Battery", > "RM215DO.", "SCTemp", "SCSpCond", "SCDO.Conc", "SCDepth", "SCpH", > "SCORP", "SCTurbidity.", "SCBattery", "SCDO.", "RM202Temp", "RM202SpCond", > "RM202DO.Conc", "RM202Depth", "RM202pH", "RM202ORP", "RM202Turbidity", > "RM202Battery", "RM202DO.", "RM198Temp", "RM198SpCond", "RM198DO.Conc", > "RM198Depth", "RM198pH", "RM198ORP", "RM198Turbidity.", "RM198Battery", > "RM198DO.", "HCTemp", "HCSpCond", "HCDO.Conc", "HCDepth", "HCpH", > "HCORP", "HCTurbidity.", "HCBattery", "HCDO.", "RM190Temp", "RM190SpCond", > "RM190DO.Conc", "RM190Depth", "RM190pH", "RM190ORP", "RM190Turbidity.", > "RM190Battery", "RM190DO.", "BCTemp", "BCSpCond", "BCDO.Conc", > "BCDepth", "BCpH", "BCORP", "BCTurbidity.", "BCBattery", "BCDO.", > "RM185Temp", "RM185SpCond", "RM185DO.Conc", "RM185Depth", "RM185pH", > "RM185ORP", "RM185Turbidity.", "RM185Battery", "RM185DO.", "RM179Temp", > "RM179SpCond", "RM179DO.Conc", "RM179Depth", "RM179pH", "RM179ORP", > "RM179Turbidity.", "RM179Battery", "RM179DO.", "RM148Temp", "RM148SpCond", > "RM148DO.Conc", "RM148Depth", "RM148pH", "RM148ORP", "RM148Turbidity.", > "RM148Battery", "RM148DO.", "RM119Temp", "RM119SpCond", "RM119DO.Conc", > "RM119Depth", "RM119pH", "RM119ORP", "RM119Turbidity.", "RM119Battery", > "RM119DO.", "RM61Temp", "RM61SpCond", "RM61DO.Conc", "RM61Depth", > "RM61pH", "RM61ORP", "RM61Turbidity.", "RM61Battery", "RM61DO.", > "NSBL.Dflow", "RM148flow", "RM119flow", "RM61flow", "RM190heat", > "RM185heat", "RM148heat", "RM119heat", "RM61heat", "RM190DOmass", > "RM185DOmass", "RM148DOmass", "RM119DOmass", "RM61DOmass"), class = "factor")) > > > thanks > > -- > Stephen Sefick > Research Scientist > Southeastern Natural Sciences Academy > > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. We are mammals, and have not exhausted the > annoying little problems of being mammals. > > -K. Mullis > > ______________________________________________ > 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. >