Re: [R] How to replace the values in a column

2012-02-29 Thread Rui Barradas
Hello, Try the following. (In Andrija's code I've changed 'df' to 'DF', 'df' is a R function name) DF <- read.table( ... etc ... tc <- textConnection(" Column1(Gen)Column2(Name) A_1 Wynda A_2 A_2 B_1

Re: [R] How to replace the values in a column

2012-02-28 Thread andrija djurovic
Hi. You can do something like this: df <- read.table(textConnection(" GenRep A_1 1 A_1 2 A_2 1 A_2 2 B_1 1 B_1 2 B_3 1 B_3 2 OP1_1 1 OP1_1 2 OP1_5 1 OP1_5 2"),header=TRUE,stringsAsFactors=FALSE) str(df) #adding a new column cbind(df,ncol =

Re: [R] How to replace the values in a column

2012-02-28 Thread ilai
Hannah, If Gen is a factor you can simply build the new factor "on top" of it: dataframe$Gen<- factor( c('Wynda' , 'A_2' , 'B_1' , 'Wynda' , 'Wynda' , 'OP1_5')[Gen] ) Just make sure the replacement labels are in the same order as levels(Gen). Cheers On Tue, Feb 28, 2012 at 8:39 PM, hannahmaohua

[R] How to replace the values in a column

2012-02-28 Thread hannahmaohuang
Dear All, I've been searching relevant topics about replacing values, none seemed to be applicable to me... I have a file with many many varieties, and want to replace some of them into different names. I tried various of ways, still don't know how to do that most efficiently.. Here is part of th