take a look at match or maybe merge >-----Original Message----- >From: Adrian Dusa [mailto:[EMAIL PROTECTED] >Sent: Wednesday, May 19, 2004 8:44 AM >To: [EMAIL PROTECTED] >Subject: [R] indexing question > > >Hi, > >I have a problem and a rather poor solution that I would like >to improve. >There a 2 datasets with different number of cases like this: > >Dataset 'poploc' Dataset 'siruta' > >Case no. SIRUTA TYPE Case no. >SIRUTA TYPE >1 1017 0 1 >1017 3 >2 1026 0 2 >1020 5 >3 42711 0 3 >1026 4 >... ... >13000 100234 0 ... > 16000 >160241 3 > >I want to bring the TIP variable in the 'poploc' dataset >according to the >SIRUTA variable (which has unique codes for each case, in both >datasests). >The resulting dataset 'poploc' should look like this: > >Case no. SIRUTA TYPE >1 1017 3 >2 1026 4 >3 42711 3 >... >13000 100234 5 > >My current solution involves a combination of FOR looping and >indexing, which >takes about 3 minutes to complete. > >for (i in 1:nrow(siruta)) >poploc$TIP[poploc$SIRUTA %in% siruta$SIRUTA[i]] <- siruta$TIP[i] > >I'm sure there are more clever solutions, any help >appreciated. Thank you! >Adrian > >______________________________________________ >[EMAIL PROTECTED] mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
