I've already found how to change levels of a factor in an easy way. My problem is that I have three columns (factors) and they have some levels in common. I need to be sure that I can change - in a general way because the next year the levels of this factor will have a different name - equal levels among factor for the same "new" level. Example:
> data<-read.table(head=T,"F2_SULMaturação_Conjunta.txt")
> data[25:35,1:5]
OBS POP IDPOP IDMOM IDDAD
25 25 MUR3 MUR3 BMXPotênciaRR M9056RR
26 26 MUR9 MUR9 BMXPotênciaRR M8221RR
27 27 MUR18 MUR18 BMXPotênciaRR P98N71
28 28 MUR29 MUR29 BMXPotênciaRR CONQUISTA
29 29 GENIT BMXPotênciaRR 0 0
30 30 GENIT NA5909RR 0 0
31 31 MUR25 MUR25 DM5958IPRO CONQUISTA
32 32 MUR27 MUR27 TMG7062IPRO CONQUISTA
33 33 GENIT DM5958IPRO 0 0
34 34 GENIT P98N71 0 0
35 35 MUR1 MUR1 BMXApoloRR M9056RR
> levels(data$IDDAD)
[1] "0" "CONQUISTA" "M8221RR" "M9056RR" "P98N71"
> levels(data$IDMOM)
[1] "0" "BMXApoloRR" "BMXPotênciaRR" "DM5958IPRO"
"DM6563IPRO"
[6] "NA5909RR" "TMG7062IPRO"
> levels(data$IDPOP)
[1] "BMXApoloRR" "BMXPotênciaRR" "CONQUISTA" "DM5958IPRO"
"DM6563IPRO"
[6] "M8221RR" "M9056RR" "MUR1" "MUR13" "MUR14"
[11] "MUR15" "MUR16" "MUR17" "MUR18" "MUR2"
[16] "MUR24" "MUR25" "MUR26" "MUR27" "MUR28"
[21] "MUR29" "MUR3" "MUR7" "MUR8" "MUR9"
[26] "NA5909RR" "P98N71" "TMG7062IPRO"
Notice that some levels of "IDPOP", "IDMOM" and "IDDAD" are the same i.e.: "BMXPotênciaRR". I'm looking for a code, maybe that allows me to set two vectors with respective "new levels" in the same line, and make this change in batch. Example:
> a<-c("BMXPotênciaRR","DM5958IPRO", "TMG7062IPRO")
> b<-c("1","2","3")
> a
[1] "BMXPotênciaRR" "DM5958IPRO" "TMG7062IPRO"
> b
[1] "1" "2" "3"
Since I have to write the code in a general way, I don't intend to write the levels, but capture they by "levels(...)".