RE: [R] indexing question

About this list Date view Thread view Subject view Author view Attachment view

From: Benjamin.STABLER@odot.state.or.us
Date: Thu 20 May 2004 - 01:50:18 EST


Message-id: <76A000A82289D411952F001083F9DD06047FE69F@exsalem4-bu.odot.state.or.us>

take a look at match or maybe merge

>-----Original Message-----
>From: Adrian Dusa [mailto:adi@roda.ro]
>Sent: Wednesday, May 19, 2004 8:44 AM
>To: r-help@stat.math.ethz.ch
>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
>
>______________________________________________
>R-help@stat.math.ethz.ch 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

______________________________________________
R-help@stat.math.ethz.ch 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


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST