Skip to content
Back to formatted view

Raw Message

Message-ID: <67029D1C-F089-4B5E-9ACD-B9362989116A@gmail.com>
Date: 2011-10-06T12:37:06Z
From: Thomas Friedrichsmeier
Subject: Running *slow*

Anyone got any hints on how to make this code more efficient? An early  
version (which to be fair did more than this one is) ran for 330 hours  
and produced no output.

I have a two column table, Dat, with 12,000,000 rows and I want to  
produce a lookup table, ltable, in a 1 dimensional matrix with one  
copy of each of the values in Dat:

for (i in 1:nrow(Dat))
{
for (j in 1:2)
{
#If next value is already in ltable, do nothing
if (is.na(match(Dat[i,j], ltable))){ltable <- rbind(ltable,Dat[i,j])}
}
}

but it takes forever to produce anything.

Any advice gratefully received.

Thomas