Thanks everyone for your help. All of the solutions posted (Arun, David, Jim and Petr) worked for my problem.
From: arun <smartpink...@yahoo.com> To: Sarah Auburn <saub...@yahoo.com> Cc: R help <r-help@r-project.org> Sent: Tuesday, 3 July 2012, 2:13 Subject: Re: [R] R sub query Hi, Either of these should work: m<-matrix(c(".:0:0,0", ".:2:0,2", ".:194:193,1", ".:56:0,56", ".:58:50,8", ".:13:0,13", ".:114:114,0", ".:75:75,0"), nrow=2) gsub("^\\.:[[:digit:]]+:","",m) [,1] [,2] [,3] [,4] [1,] "0,0" "193,1" "50,8" "114,0" [2,] "0,2" "0,56" "0,13" "75,0" gsub("^\\.:\\d+:","",m) [,1] [,2] [,3] [,4] [1,] "0,0" "193,1" "50,8" "114,0" [2,] "0,2" "0,56" "0,13" "75,0" A.K. ----- Original Message ----- From: Sarah Auburn <saub...@yahoo.com> To: "r-help@r-project.org" <r-help@r-project.org> Cc: Sent: Monday, July 2, 2012 4:15 AM Subject: [R] R sub query Hello, I would like to substitute a substring of characters defined by a specific start and end sequence. i.e. in the example matrix below, I would like to substitute ".:X:" with "", where X varies in sequence... m<-matrix(c(".:0:0,0", ".:2:0,2", ".:194:193,1", ".:56:0,56", ".:58:50,8", ".:13:0,13", ".:114:114,0", ".:75:75,0"), nrow=2) output required: [,1] [,2] [,3] [,4] [1,] "0,0" "193,1" "50,8" "114,0" [2,] "0,2" "0,56" "0,13" "75,0" Thank you for any help Sarah [[alternative HTML version deleted]] ______________________________________________ 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. [[alternative HTML version deleted]]
______________________________________________ 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.