Re: [R] replace string values with numbers

2012-09-26 Thread JiangZhengyu
Hi Guys, Both of your ways worked. Thanks a lot for your help! Best,Zhengyu > Date: Wed, 26 Sep 2012 16:28:29 -0700 > From: smartpink...@yahoo.com > Subject: Re: [R] replace string values with numbers > To: zhyjiang2...@hotmail.com > CC: r-help@r-project.org; dwinsem...@comc

Re: [R] replace string values with numbers

2012-09-26 Thread arun
]<-3 Gene   P1 P2 P3 #1 CG CG  3 #2 -- -- AC #3 -- AC CC #4 AC -- AC  str(Gene) #'data.frame':    4 obs. of  3 variables: # $ P1: chr  "CG" "--" "--" "AC" # $ P2: chr  "CG" "--" "AC" "--" # $ P3: chr  &quo

Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 2:27 PM, David Winsemius wrote: > > On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote: >> >> Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 >> CG CG GG >> -- -- AC >> -- AC CC >> AC -- AC I tried to replace all the GG with a value 3. >> Gene[Gene=="GG

Re: [R] replace string values with numbers

2012-09-26 Thread David Winsemius
On Sep 26, 2012, at 12:52 PM, JiangZhengyu wrote: > > > > > Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 > CG CG GG > -- -- AC > -- AC CC > AC -- AC I tried to replace all the GG with a value 3. > Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp

[R] replace string values with numbers

2012-09-26 Thread JiangZhengyu
Hi everyone, I have a data frame Gene with SNPs eg. P1 P2 P3 CG CG GG -- -- AC -- AC CC AC -- AC I tried to replace all the GG with a value 3.Gene[Gene=="GG"]<-3 It always give me: Warning in `[<-.factor`(`*tmp*`, thisvar, value = 3) : invalid factor level, NAs generated Does a