similar to: for loop Vs apply function Vs foreach (REvolution enhancement)

Displaying 20 results from an estimated 6000 matches similar to: "for loop Vs apply function Vs foreach (REvolution enhancement)"

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
2011 Feb 11
1
foreach with registerDoMC on R 2.12.0 OSX 10.6 --- errors and warnings
some hints for the search engines. I just did install.packages("foreach") install.packages("doMC") library(doMC) registerDoMC() library(foreach) > foreach(i = 1:3) %dopar% sqrt(i) The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec(). Break on
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,
2012 Feb 18
3
foreach %do% and %dopar%
Hi everyone, I'm working on a script trying to use foreach %dopar% but without success, so I manage to run the code with foreach %do% and looks like this: The code is part of a MCMC model for projects valuation, returning the most important results (VPN, TIR, EVA, etc.) of the simulation. foreach (simx = NsimT, .combine=cbind, .inorder=FALSE, .verbose=TRUE) %do% { MCPVMPA = MCVAMPA[simx]
2011 Aug 17
1
R cmd check and multicore foreach loop
Hi, in R 2.12.1, R CMD check hangs when building a vignette that uses a foreach loop with the doMC parallel backend. This does not happen in R 2.13.1, nor if I use doSEQ instead of doMC. All versions of multicore, doMC and foreach are the same on both my R installations. Has anybody encountered a similar issue? Thank you. Renaud ### UNIVERSITY OF CAPE TOWN This e-mail is subject to the
2011 Jun 28
1
doMC - compiler - concatenate an expression vector into a single expression?
Hi, this post is about foreach operators, the compiler package and the last update of doMC that includes support for the compiler functionality. I am using a home-made %dopar%-like operator that adds some custom expression to be executed before the foreach loop expression itself (see sample code below). It used to work perfectly with doMC 1.2.1, but with the introduction of the compiler
2010 Nov 16
2
Debugging segfault in foreach
Hi, I'm using R-2.12 on a linux 64bit machine. When I run a chunk of code inside a foreach() %do% { ...} or %dopar% {...} (with doMC backend) I keep getting a segfault. Running the *same* code within lapply(something, function(x) ... ) doesn't result in any segfaults. I'll paste the output below, but I'm not sure it would be helpful. I'm more curious how to go about smoking
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
2011 Jul 02
5
%dopar% parallel processing experiment
dear R experts--- I am experimenting with multicore processing, so far with pretty disappointing results. Here is my simple example: A <- 100000 randvalues <- abs(rnorm(A)) minfn <- function( x, i ) { log(abs(x))+x^3+i/A+randvalues[i] } ?## an arbitrary function ARGV <- commandArgs(trailingOnly=TRUE) if (ARGV[1] == "do-onecore") { ?library(foreach) ?discard <-
2011 Jul 04
1
writeLines + foreach/doMC
Hi I'm processing sequencing data trying to collapsing the locations of each unique sequence and write the results to a file (as storing that in a table will require 10GB mem at least) so I wrote a function that, given a sequence id, provide the needed line to be stored library(doMC) # load library registerDoMC(12) # assign the Number of CPU
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:
2012 Feb 23
1
segfault when using data.table package in conjunction with foreach
Hi all, I'm trying to use the package read.table within a foreach loop. I'm grabbing 500M rows of data at a time from two different files and then doing an aggregate/tapply like function in read.table after that. I had planned on doing a foreach loop 39 times at once for the 39 files I have, but obviously that won't work until I figure out why the segfault is occurring. The
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
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
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
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)
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
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
2017 Jun 13
1
fedback from foreach
Hi useRs, I am running a foreach loop and hoped to get a small message when it hits a multiple of 1000, but it does not work. p <- foreach(i=1:10000, .combine='c') %dopar% { if(i%%1000==0) print(i) sqrt(i) } What is the proper way to do it. Thanks everybody. Stephen B [[alternative HTML version deleted]]
2010 Apr 29
2
dopar parallel assignments
Hi guys, I was wondering why this piece of code doesn't work: foreach (i = c(1.25,1.50)) %dopar% { assign(paste("test_",i,sep=""),i) } but, this does: foreach (i = c(1.25,1.50)) %do% { assign(paste("test_",i,sep=""),i) } Obviously, the difference is %dopar% vs. %do%. If I use %do%, I get objects test_1.25 and test_1.50, but I don't get these