Thanks everyone for your help. All of the solutions posted (Arun, David, Jim
and Petr) worked for my problem.
From: arun
To: Sarah Auburn
Cc: R help
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", &quo
,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"
On Jul 2, 2012, at 4:15 AM, Sarah Auburn wrote:
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:
Hi
I am not at all an expert in regular expressions but
gsub("^[[:punct:]]+[[:digit:]]+:", "",m)
does the output you want. Maybe by chance :-)
Regards
Petr
>
> Hello,
> I would like to substitute a substring of characters defined by a
specific
> start and end sequence.
> i.e. in the example
Will this do:
> 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)
>
> m
[,1] [,2] [,3][,4]
[1,] ".:0:0,0" ".:194:193,1" ".:58:50,8" ".:114:114,0"
[2,] ".:2:0,2" ".:56:0,56" ".:13:0,13" ".:75
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
6 matches
Mail list logo