| To: | gerald.jean@dgag.ca |
|---|---|
| Subject: | Re: Speeding up a for loop |
| From: | "David L Lorenz" <lorenz@usgs.gov> |
| Date: | Wed, 24 Nov 2004 08:20:33 -0600 |
| Cc: | s-news@wubios.wustl.edu, s-news-owner@lists.biostat.wustl.edu |
Gerald,
Why not merge the data frames on newprof and CodeProf and then make the
assignment?
Dave
gerald.jean@dgag.ca
Sent by: To:
s-news@wubios.wustl.edu
s-news-owner@lists.biosta cc:
t.wustl.edu Subject: [S] Speeding
up a for loop
11/24/2004 08:07 AM
Hello S-users,
I am running the following loop at the top level --- not in a function ---
and it takes for ever! It is running since 16h00 yesterday, hence over 17
hours so far. It is not using too much memory though. The data.frame it
is looping over is small, 284 observations, while the data.frame where the
assignements take place is huge, over 2M records. Since I have two more
data.frames, even bigger, where I have to run the same loop I am wondering
if there is a way to speed up this loop or another way to get the task
done?
> for (i in 1:nrow(StatCanCNP)) {
+ QcProf.Ass.b2[QcProf.Ass.b2[, 'newprof'] == StatCanCNP[i, 'CodeProf'],
+ c('Educ', 'Indus')] <- StatCanCNP[i, c('Education',
'CdIndus')]
+ }
The variables "Educ" and "Indus" in the large data.frame have been created
beforehand.
Here are the specs of my installation.
S-PLUS : Copyright (c) 1988, 2004 Insightful Corp.
S : Copyright Lucent Technologies, Inc.
Version 6.2.1 for Sun SPARC, SunOS 5.8, 64-bit : 2004
Thanks for any clues,
Gérald Jean
Analyste-conseil (statistiques), Actuariat
télephone : (418) 835-4900 poste (7639)
télecopieur : (418) 835-6657
courrier électronique: gerald.jean@dgag.ca
"In God we trust all others must bring data" W. Edwards Deming
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu. To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message: unsubscribe s-news
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Speeding up a for loop, Richard M. Heiberger |
|---|---|
| Next by Date: | interaction plots within trellis, Olivier Renaud |
| Previous by Thread: | Re: Speeding up a for loop, Richard M. Heiberger |
| Next by Thread: | interaction plots within trellis, Olivier Renaud |
| Indexes: | [Date] [Thread] [Top] [All Lists] |