Re: [R] match and substitute two variables

2012-12-03 Thread arun
ot; A.K. - Original Message ----- From: irene To: r-help@r-project.org Cc: Sent: Monday, December 3, 2012 10:32 AM Subject: [R] match and substitute two variables Hello, I have two variables (of different length and from two different data frames): code<- c("101001",  "

Re: [R] match and substitute two variables

2012-12-03 Thread irene
It works perfectly, thank you! -- View this message in context: http://r.789695.n4.nabble.com/match-and-substitute-two-variables-tp4651893p4651906.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list http

Re: [R] match and substitute two variables

2012-12-03 Thread Rui Barradas
Hello, Try the following. for(nm in name){ code[grep(gsub("[ [:alpha:]]+", "", nm), code)] <- nm } code Hope this helps, Rui Barradas Em 03-12-2012 15:32, irene escreveu: Hello, I have two variables (of different length and from two different data frames): code<- c("101001", "1032", "1

[R] match and substitute two variables

2012-12-03 Thread irene
Hello, I have two variables (of different length and from two different data frames): code<- c("101001", "1032", "102", "101001", "102", "1032"); name<- c("101001 Alta", "102 Bassa", "1032 Media"); and I would like to substitute the first variable with the second variable according to their sh