[R] How to replace the values in a column
hannahmaohuang
hannahmaohuang at gmail.com
Wed Feb 29 04:39:06 CET 2012
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 the example data:
Gen Rep
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
For example, I want to replace A_1, B_3, OP1_1 into different name
"Wynda"
So that the expected file should become:
Gen Rep
Wynda 1
Wynda 2
A_2 1
A_2 2
B_1 1
B_1 2
Wynda 1
Wynda 2
Wynda 1
Wynda 2
OP1_5 1
OP1_5 2
I have created a link file, which contains two rows, translating which Gen
correlating to which Name. Not sure if this file helps or not, example as
below:
Column1(Gen) Column2(Name)
A_1 Wynda
A_2 A_2
B_1 B_1
B_3 Wynda
OP1_1 Wynda
OP1_5 OP1_5
Though I can replace one by one in excel, since there are too many files and
too many reps, it'll be very time-consuming also easy to make mistakes.
Please give me any guidance or help in terms of finish this with R.
Thanks so much !
Sincerely
Hannah
--
View this message in context: http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4430448.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list