similar to: For->lapply->parallel apply

Displaying 20 results from an estimated 1000 matches similar to: "For->lapply->parallel apply"

2011 Apr 11
1
Mclapply and print statement
Dear all. I am using the mclapply function to split my code to the many cores my system has. It seems that is working fine. This is the parallel version of lcapply. The only problem that I seem to have is that the printf cannot print messages. The ideal to me is to have fro my function an output of the form Shadowlist<-mclapply(1:dimz, function(i) { print(sprintf('Creating the
2011 Apr 11
1
Comparing execution times
Dear all, In my 'simple' computer I was running some experiments to help me understand how faster a multicore lapply will be. I thought it might be interesting for some people to look at the results. Even though are not accurate, still might be a good indicator how much improvement there can be. A.Case. The classic: for 1:100 for (i in c(1:dimz)){ print(sprintf('Creating the %d
2011 Apr 27
6
Assignments inside lapply
Dear all I would like to ask you if an assignment can be done inside a lapply statement. For example I would like to covert a double nested for loop for (i in c(1:dimx)){ for (j in c(1:dimy)){ Powermap[i,j] <- Pr(c(i,j),c(PRX,PRY),f) } } to something like that: ij<-expand.grid(i=seq(1:dimx),j=(1:dimy)) unlist(lapply(1:nrow(ij),function(rowId) { return
2011 Jul 22
0
Mclapply prints once
Dear all I have the following code that works in paraller (and is pretty fast actually) The only problem I still have is that every core just prints only once. dimz<-1000 Shadowlist<-mclapply(1:dimz, function(i) { ????????????????????????????? print(sprintf('Creating the %d map',i)); ????????????????????????????? createField(x=x, y=y, model=model,
2010 Sep 06
0
How R converts data between objects
Hello everyone. I would kindly request your help concerning how R converts data between different structrures. In the following example please keep attention on the following two 1) I create f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean, variance, nugget, scale, alpha)) with image(x,y,f) and image(f) I get exactly the same image. then 2)I try to store f inside a raster
2011 Mar 30
4
a for loop to lapply
Dear all, I am trying to learn lapply. I would like, as a test case, to try the lapply alternative for the Shadowlist<-array(data=NA,dim=c(dimx,dimy,dimmaps)) for (i in c(1:dimx)){ Shadowlist[,,i]<-i } ---so I wrote the following--- returni <-function(i,ShadowMatrix) {ShadowMatrix<-i} lapply(seq(1:dimx),Shadowlist[,,seq(1:dimx)],returni) So far I do not get same results
2015 Feb 24
2
iterated lapply
> On Feb 24, 2015, at 10:50 AM, <luke-tierney at uiowa.edu> wrote: > > The documentation is not specific enough on the indented semantics in > this situation to consider this a bug. The original R-level > implementation of lapply was > > lapply <- function(X, FUN, ...) { > FUN <- match.fun(FUN) > if (!is.list(X)) > X <-
2015 Feb 26
1
iterated lapply
> On Feb 25, 2015, at 5:35 PM, Benjamin Tyner <btyner at gmail.com> wrote: > > Actually, it depends on the number of cores: Under current semantics, yes. Each 'stream' of function calls is lazily capturing the last value of `i` on that core. Under Luke's proposed semantics (IIUC), the result would be the same (2,4,6,8) for both parallel and serial execution. This is
2012 Feb 05
2
vectors of matrix as iinput to lapply
Dear all I am using lapply (actually mclapply that share the same syntax). I want to call the same function that takes as input a vector. My initial data structure is a matrix that I want to cut it to multiple vectors (one vector for every row of the matrix) and then feed that to the function by using mclapply. Could you please help me converting the matrices to nrow times vectors. I would
2007 May 21
1
size limit in R?
Hi, Please see the email exchanges below. I am having trouble generating output that is large enough for our needs, specifically when using the GaussRF function. However, when I wrote Dr. Schlather (the author of the GaussRF function), he indicated that there is also a limit imposed by R itself. Is this something that we can overcome? Thank you very much for any assistance you may provde.
2002 Sep 30
0
using step function in functions
Help! I am a new R user. It has been slow getting up to speed, but definitely rewarding. I have come up against a problem I can't handle. I would very much appreciate any help. I am writing a vector auto regression (VAR) function that utilizes existing R statistical functions. I would like to use the step function to do step-wise elimination on each univariate time series model. No
2011 Oct 31
2
lapply and Two TimeStamps as input
Dear all, I have a function that recognizes the following format for timestamps "%Y-%m-%d %H:%M:%S" my function takes two input arguments the TimeStart and TimeEnd I would like to help me create the right list with pairs of TimeStart and TimeEnd which I can feed to lapply (I am using mclapply actually).  For every lapply I want two inputs to be fed to my function. I only know how to
2004 Dec 28
1
RandomFields: Controling seed with GaussRF
Hi, I'm using RF to simulate a correlated variable with GaussRF set.seed=1 GaussRF(sim.kfinegrid, grid=F, model="exponential", param=c(0,0.5,0,0.2)) However when I simulate again using the same random seed I get different results. > set.seed=1 > summary(GaussRF(sim.kfinegrid, grid=F, model="exponential", param=c(0,0.5,0,0.2))) Min. 1st Qu. Median Mean 3rd
2010 Feb 28
2
lapply with data frame
I'm a bit confused on how to use lapply with a data.frame. For example. lapply(data, function(x) print(x)) WHAT exactly is passed to the function. Is it each ROW in the data frame, one by one, or each column, or the entire frame in one shot? What I want to do apply a function to each row in the data frame. Is lapply the right way. A second application is to normalize a column value by
2011 May 30
0
2D random walk with traps convert C++ code to R code
Hello, I have a C++ code for 2D random walks with traps and I want to convert it in a R code with its syntaxs, can anyone help??????? It's easy for me to adapt the body but I want help with the beginig (variable declaration) and th end exporting the output to a file ( like write.table() or sink() ) Thank you... #include <iostream> #include <math.h>#include
2011 Apr 22
1
ggplot
Hello everyone, I am using ggplot to plot but I am getting the following error which I do not understand Error: geom_text requires the following missing aesthetics: label My code is dimx<-256 library(ggplot2) dev.new() xandy<-expand.grid(seq(1:dimx),seq(1:dimy)) xx<-data.frame(xandy[[1]],xandy[[2]],Powermap=Powermap) subsetxx<-subset(xx, xx$Powermap>threshold)
2011 Oct 22
1
lapply to return vector
Dear all I have wrote the following line return(as.vector(lapply(as.data.frame(data),min,simplify=TRUE))); I want the lapply to return a vector as it returns a list with elements as shown below List of 30001 $ V1 : num -131 $ V2 : num -131 $ V3 : num -137 $ V4 : num -129 $ V5 : num -130 as you can see I have already tried the simplify=TRUE and also the as.vector() but both
2015 Feb 24
3
iterated lapply
From: Daniel Kaschek <daniel.kaschek at physik.uni-freiburg.de> > ... When I evaluate this list of functions by > another lapply/sapply, I get an unexpected result: all values coincide. > However, when I uncomment the print(), it works as expected. Is this a > bug or a feature? > > conditions <- 1:4 > test <- lapply(conditions, function(mycondition){ >
2014 Jun 17
2
No es un problema de tm tienes doc.corpus vacío
No es un problema de tm ni de SnowfallC ni de mcapply (por el path utilizas linux, en windows mcapply según el manual no va bien) No defines bien los objetos que pasas. Pasas doc.corpus en lugar de corpus ( o asignas a corpus en lugar de a doc.corpus) . Depura los programas cuando salga un error de objeto, como te pone en el Error que pasas . Temporalmente lo tienes arreglado en
2012 Nov 12
1
How to generate a random field with truncated marginal distributions?
I have asked the same question on stackoverflow but did not get a satisfying answer. I am trying to simulate a lognormal spatial random field but I need the simulated value in a certain range. So I need some easy to use functions to generate a truncated Gaussian field to start with. To be specific, I need a function like GaussRF from the RandomFields package or grf from the geoR package to