s-news
[Top] [All Lists]

Extraction

To: s-news@lists.biostat.wustl.edu
Subject: Extraction
From: Tristan Lorino <tristan.lorino@lcpc.fr>
Date: Fri, 6 Jan 2006 10:01:03 +0100
Organization: LCPC
Reply-to: Tristan Lorino <tristan.lorino@lcpc.fr>
Hi,

I have a file with 466,200 lines and 46,000 subjects (there is a
'ident' column for identify subjects, in place 13). I would like to extract from
this file one record by subject.
I created a new column, in place 14, and wrote:

data[1,14]_1
for (i in 1:19999)
{
   data[i+1,14]_ifelse(data[i+1,13]==data[i,13],0,1)
}

So if a line corresponds to the same subject as the previous line,
there is a "0" in the new column, and a "1" if this line concerns a
new subject. Endly, I keep only lines with "1".

But I need to repeat this loop for each group of 20,000 lines... it's
so long! Is there a quicker way?

Thank you,
Tristan Lorino


-- 
Laboratoire Central des Ponts et Chaussées
[Division ESAR ? Section AGR]
Route de Bouaye BP 4129
44341 Bouguenais Cedex
France
Tél 33 (0)2 40 84 56 18
Fax 33 (0)2 40 84 59 92


<Prev in Thread] Current Thread [Next in Thread>