[R] How to replace the values in a column
Rui Barradas
rui1174 at sapo.pt
Wed Feb 29 17:12:37 CET 2012
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 B_1
B_3 Wynda
OP1_1 Wynda
OP1_5 OP1_5
")
TransTable <- read.table(tc, header=TRUE, stringsAsFactors=FALSE)
close(tc)
nrTrans <- nrow(TransTable)
for(iTrans in 1:nrTrans){
i <- DF$Gen == TransTable[iTrans, 1]
DF$Gen[i] <- TransTable[iTrans, 2]
}
# See first 6 lines of result
head(DF)
That's it.
Hope this helps,
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/How-to-replace-the-values-in-a-column-tp4430448p4431983.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list