similar to: Building a big.matrix using foreach

Displaying 20 results from an estimated 1000 matches similar to: "Building a big.matrix using foreach"

2009 Jul 20
2
kmeans.big.matrix
Hi, I'm playing around with the 'bigmemory' package, and I have finally managed to create some really big matrices. However, only now I realize that there may not be functions made for what I want to do with the matrices... I would like to perform a cluster analysis based on a big.matrix. Googling around I have found indications that a certain kmeans.big.matrix() function should
2009 Jul 22
5
Find multiple elements in a vector
Hi, Given a vector, say x=sample(0:9,10) x [1] 0 6 3 5 1 9 7 4 8 2 I can find the location of an element by which(x==2) [1] 10 but what if I want to find the location of more than one number? I could do c(which(x==2),which(x==3)) but isn't there something more streamlined? My first guess was y=c(2,3) which(x==y) integer(0) which doesn't work. I haven't found any clue in the R
2009 Jul 14
5
Nested for loops
Hi, I have spent some time locating a quite subtle (at least in my opinion) bug in my code. I want two nested for loops traversing the above-diagonal part of a square matrix. In pseudo code it would something like for i = 1 to 10 { for j = i+1 to 10 { // do something } } However, trying to do the same in R, my first try was for (i in 1:10) { for (j in (i+1):10) { //
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
2009 Sep 30
5
Rounding error in seq(...)
Hi, Today I was flabbergasted to see something that looks like a rounding error in the very basic seq function in R. > a = seq(0.1,0.9,by=0.1) > a [1] 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 > a[1] == 0.1 [1] TRUE > a[2] == 0.2 [1] TRUE > a[3] == 0.3 [1] FALSE It turns out that the alternative > a = (1:9)/10 works just fine. Are there any good guides out there on how to deal
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
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
2010 Mar 06
1
Is parralel processing automatically done on multi-core CPU's?
Hi, I just noticed this article, http://www.howtoforge.net/fully-utilizing-your-x-core-cpu which uses http://code.google.com/p/ppss/ for parralel processing. So, can anyone tell me if parralel processing happens automatically on CentOS, or would I need to use this script as well? We mainly have Dual Core & Dual CPU, Dual Core (i.e. 8 cores) servers and it would be benefitial to know whether
2012 Jan 03
1
Error when using foreach package for parralelization
Hi, i tried to find the answer but didn't so my apologies if the question is obvious ! I'm trying to parallelize the following R code : pk2test = c(1:16,(12*16+1):(12*16+16),(16*16+1):(16*16+16),(20*16+1):(20*16+16)) score.mat = matrix(nc=16*4,nr=16*4) for(i in 1:(16*4)) { for(j in i:(16*4)) { score.mat[i,j] = score.mat[j,i] =
2009 Jul 20
5
heatmap plot
Dear R community! I am trying to create a heatmap based on the following data. As you can see the diagonal (0,0 to 10,10) is always 0). If I run the heatmap command like i posted it I get a graph with horizontal lines. What is my mistake? > heatmap(activity.matrix, Rowv = NA, Colv = NA, scale="column", xlab="x Compounds", ylab="y Compounds",
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]]
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 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 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",
2015 May 11
1
Foreach %dopar% operator incorrectly load balancing
Dear R-SIG-Debian, I am using R version 3.1.2 with rstudio-server 0.98.113 on debian build 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux. I often use the %dopar% operator in from the foreach package to run code in parallel. However, the only other use on the box seemingly installed a few items and suddenly %dopar% will use far more than the number of cores I am specifying and
2017 Dec 07
2
parallel computing with foreach()
I have used foreach() for parallel computing but in the current problem, it is not working. Given the volume and type of the data involved in the analysis, I will try to give below the complete code without reproducible example. In short, each R environment will draw a set of separate files, perform the analysis and dump in separate folders. splist <- c("juoc", "juos",
2009 Jul 13
2
graph: axis label font
Hi, excuse me for my english, i am using R on windows and i have to do several graphs with axis labels and the axis text thicks has a specified font type, (Arial) and a specified font size. How can i do these? Thank you in advance -- View this message in context: http://www.nabble.com/graph%3A-axis-label-font-tp24463974p24463974.html Sent from the R help mailing list archive at Nabble.com.
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)
2017 Dec 07
0
parallel computing with foreach()
Your code generates an error that has nothing to do with dopar. I have no idea what your function stack is supposed to do; you may be inadvertently calling utils::stack which would produce this kind of error: > stack(1:25, RAT = FALSE) Error in data.frame(values = unlist(unname(x)), ind, stringsAsFactors = FALSE) : arguments imply differing number of rows: 25, 0 HTH, Peter On Wed, Dec 6,
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]