Displaying 20 results from an estimated 7000 matches similar to: "foreach takes foreever?"
2011 Oct 17
2
Foreach (doMC)
Hello,
I am trying to run a small example with foreach, but I am having some
problems. Here is the code:
*library(doMC)
registerDoMC()
zappa = list()
frank = list()
foreach (i = 1:4) %dopar% {
zappa[[i]] = kmeans (iris[-5],4)
frank[[i]] = warnings()
}*
The code runs without error. However the zappa and frank will be empty
lists.
If I use regular *for *instead, the list will be filled up
2009 Oct 08
3
foreach loop - rejection method
Hi Everybody,
Thanks in advance for your help.
This is my first time using the foreach statement and I cant get it to work
properly so here is what i have
test<-function(){
repeat {
cand2[l-1]<-rinvgamma(1,phi,lambda[l-1])
q2<-dinvgamma(cand2[l-1],phi,lambda[l-1])
p2<-cand2[l-1]^-1.5*exp(-y[l]^2/(2*cand2[l-1]))*exp(-((log(cand2[l-1])-mu_t_cand[l-1])^2)/2*sigmasq)
2012 Jan 19
1
converting a for loop into a foreach loop
Dear all,
Just wondering if someone could help me out converting my code from a for()
loop into a foreach() loop or using one of the apply() function. I have a
very large dataset and so I'm hoping to make use of a parallel backend to
speed up the processing time. I'm having trouble getting selecting three
variables in the dataset to use in the foreach() loops. My for() loop code
is:
2011 May 11
1
foreach(): how to do calculations "between" two foreach loops?
Dear expeRts,
is it possible to carry out calculations between different foreach() calls?
As for nested loops, you want to carry out calcuations not depending on the inner
loop only once and not for each iteration of the innermost loop.
Cheers,
Marius
library(foreach)
foreach(i=1:3) %:%
foreach(j=1:2) %do% {
i <- i+1
print(paste(i,j))
}
foreach(i=1:3) %:%
i
2011 Feb 25
1
Question about foreach (with doSNOW), is that a bug?
Hi all,
Within a foreach loop with doSNOW, we cant call functions which come from
the non-default package. We need to load(require/library) the package once
more within the foreach loop. Anyone knows why would happen like this? Is it
caused by the snow package and something happened when "snow" parallelize
the job?
Other than load the package once more with in the foreach loop, is
2011 Jul 12
2
foreach not recognizing functions in memory
All,
I am not understanding the scoping used in foreach when it is used
inside a function. I keep getting "could not find function" errors for
functions that are in memory when I try to use foreach within a function
call. I have a simple example below. "testFun" is in memory and works
when called by foreach directly, but when I place foreach in a function
called
2012 Nov 16
2
lubridate concatenation issue
I took a look at Hadley's lubridate which seems a very neat package, but i am having a small problem with concatenating lubridates to build vectors of it. Namely when function c( ) is applied to lubridate seems to change time to a local timezone in this particular case changing the date to previous one.
> d<-ymd('20111231')
> d
[1] "2011-12-31 UTC"
> c(d)
[1]
2012 May 08
1
revolution foreach oddity
I know this is not a revolution support forum, but as anyone noticed the
following?
I have a foreach loop to generate random samples. If I run the exact code
below in normal r (2.14.1) it works as expected, but if I run it from
revolution 4.2.0 each loop returns the same numbers.
The only way I can get revolution to give different numbers is using 1
instead of 8 in
registerDoSNOW(makeCluster(8,
2011 Jun 28
1
parallel computing with 'foreach'
Hi all,
I would like to parallelize some R code and would like to use the 'foreach'
package with a foreach loop. However, whenever I call a function from an
enabled package outside of MASS, I get an error message that a number of the
functions aren't recognized (even though the functions should be defined).
For example:
library(foreach)
library(doSMP)
library(survival)
# Create the
2013 Feb 18
3
foreach loop, stata equivalent
Hi! I'm a recent convert from Stata, so forgive my ignorance.
In Stata, I can write foreach loops (example below)
foreach var of varlist p1-p14 {
foreach y of varlist p15-p269 {
reg `var' `y'
}
}
It's looping p1-p15, p1-p16...., p1-p269, p2-p15, p2-p16,... p2-p269,...
variable pairs.
How can I write something similar in R?
I 'tried' understanding the
2012 Jul 24
1
untaring files in parallel with foreach and doSNOW?
Hello,
I'm running some code that requires untaring many files in the first step.
This takes a lot of time and I'd like to do this in parallel, if possible.
If it's the disk reading speed that is the bottleneck I guess I should not
expect an improvement, but perhaps it's the processor. So I want to try this
out.
I'm working on windows 7 with R 2.15.1 and the latest foreach
2009 Jul 18
1
Building a big.matrix using foreach
Hi there!
I have become a big fan of the 'foreach' package allowing me to do a
lot of stuff in parallel. For example, evaluating the function f on
all elements in a vector x is easily accomplished:
foreach(i=1:length(x),.combine=c) %dopar% f(x[i])
Here the .combine=c option tells foreach to combine output using the
c()-function. That is, to return it as a vector.
Today I discovered the
2012 Aug 01
1
Foreach help!
Hi,
just during these vacation days, I'm trying to approach with multicore
package
and I have some troubles with foreach.
ex.
foreach(.combine=c, ii=1:200, jj=1:500) %dopar% makefunction[ii,jj]
Command seem to work but if I see ii and jj value at the and of cycle, they
are both 200
instead than ii=200 and jj=500.
Why??
Can someone help me?
Thank you in advance.
Max
--
View this
2012 Aug 06
2
[LLVMdev] Tablegen foreach
I'm trying to find examples of the foreach pattern being used in tablegen files.
The problem I am trying to solve is to simplify the amount of tablegen code I have to produce because each operand of an instruction can be a register or a literal.
So for binary, we have 4 instructions, ternary, 8, and quaternary 16 combinations.
Instead of writing all the combinations out, I'd like to use
2010 Nov 03
1
Auto-killing processes spawned by foreach::doMC
Hi all,
Sometimes I'll find myself "ctrl-c"-ing like a madman to kill some
code that's parallelized via foreach/doMC when I realized that I just
set my cpu off to do something boneheaded, and it will keep doing that
thing for a while.
In these situations, since I interrupted its normal execution,
foreach/doMC doesn't "clean up" after itself by killing the
2012 Aug 06
0
[LLVMdev] Tablegen foreach
I think a multiclass may be a better fit for what you are trying to
do. In fact, this is the canonical example for multiclasses:
<http://llvm.org/docs/TableGenFundamentals.html#multiclass-definitions-and-instances>.
--Sean Silva
On Mon, Aug 6, 2012 at 1:55 PM, Villmow, Micah <Micah.Villmow at amd.com> wrote:
> I’m trying to find examples of the foreach pattern being used in
2009 Jul 20
2
I might be dumb : a simple question about "foreach"
Hi list,
My attention was drawn to the foreach package by recent posts...I
decided to have a look...
I'm using R.2.9.1 on Windows, I have downloaded the foreach package
today (v 1.2.1), together with iterators (v. 1.0.1) and codetools (v.0.2-2).
Full of hope I try the most simple thing of all out of the package
vignette :
> x <- foreach(i = 1:3) %do% sqrt(i)
and get :
> Erreur
2012 Oct 25
1
parallel processing with foreach
Hi,
I am trying to parallel computing with foreach function, but not able to
get the result. I know that in parallel processing, all result is collected
in list format, but I am not able to get input there.
Any help is really appreciated.
esf.m <-foreach (i = 1:n.s, .combine=rbind) %dopar% {
EV <- as.data.frame(eig$vectors[,1:n.candid[i]])
colnames(EV) <- paste("EV",
2011 Sep 29
1
efficient coding with foreach and bigmemory
I recently learned about the bigmemory and foreach packages and am trying
to use them to help me create a very large matrix. Without those
packages, I can create the type of matrix that I want with 10 columns and
5e6 rows. I would like to be able to scale up to 5e9 rows, or more, if
possible.
I have created a simplified example of what I'm trying to do, below. The
first part of the
2012 Aug 06
2
[LLVMdev] Tablegen foreach
That is what I currently have, I'm trying to simplify them even further since my multiclass file is enormous because of the amount of combinations. I have things like this:
multiclass instmcRegImm<...> {
def rr: inst<...>;
def ri: inst<...>;
def ir: inst<...>;
def ii: inst<...>;
}
multiclass instmc<...> {
defm i8 : instmcRegImm<...>;
^-- repeat for 15