Thanks, Jim!

It is exactly what I want, appreciated!



On Mon, Jun 27, 2011 at 10:22 AM, jim holtman <jholtman@gmail.com> wrote:

> Is this what you want:
>
> > test
> [1] "H.1.Y" "N.0.E" "G.1.N" "E.0.P" "W.2.G" "W.4.G" "W.3.W" "W.0.N" "D.1.H"
> > sub("\\.([0-9]+)\\.", "{\\1}", test)
> [1] "H{1}Y" "N{0}E" "G{1}N" "E{0}P" "W{2}G" "W{4}G" "W{3}W" "W{0}N" "D{1}H"
> >
>
>
> On Mon, Jun 27, 2011 at 1:18 PM, Changbin Du <changbind@gmail.com> wrote:
> > HI,  Dear R-community,
> >
> > I have one vector of the following string,
> >
> >> test<-c("H.1.Y", "N.0.E", "G.1.N", "E.0.P", "W.2.G", "W.4.G", "W.3.W",
> > "W.0.N", "D.1.H")
> >> test
> > [1] "H.1.Y" "N.0.E" "G.1.N" "E.0.P" "W.2.G" "W.4.G" "W.3.W" "W.0.N"
> "D.1.H"
> >
> > *I want to change them into*
> >
> >  "H{1}Y" "N{0}E" "G{1}N" "W{2}G" "E{0}P" "W{4}G" "W{3}W" "W{0}N" "D{1}H"
> >
> >
> > I tried the following codes:
> >
> >> new_t<-gsub(".?.", "{?}", test)
> >> new_t
> > [1] "{?}{?}{?}" "{?}{?}{?}" "{?}{?}{?}" "{?}{?}{?}" "{?}{?}{?}"
> "{?}{?}{?}"
> > [7] "{?}{?}{?}" "{?}{?}{?}" "{?}{?}{?}"
> >
> >> new_t<-gsub(".N.", "{N}", test)
> >> new_t
> > [1] "H.1.Y" "N.0.E" "G.1.N" "E.0.P" "W.2.G" "W.4.G" "W.3.W" "W.0.N"
> "D.1.H"
> >
> >> new_t<-gsub(".*.", "{*}", test)
> >> new_t
> > [1] "{*}" "{*}" "{*}" "{*}" "{*}" "{*}" "{*}" "{*}" "{*}"
> >
> >
> > Can anyone help me with this?
> >
> > Thanks!
> >
> > --
> > Sincerely,
> > Changbin
> > --
> >
> >        [[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.
> >
>
>
>
> --
> Jim Holtman
> Data Munger Guru
>
> What is the problem that you are trying to solve?
>



-- 
Sincerely,
Changbin
--

Changbin Du
DOE Joint Genome Institute

	[[alternative HTML version deleted]]

