similar to: a for loop to lapply

Displaying 20 results from an estimated 600 matches similar to: "a for loop to lapply"

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 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 Apr 09
1
For->lapply->parallel apply
Dear all, I would like to ask your help understand the subsequent steps for making my program faster. The following code: Gauslist<-array(data=NA,dim=c(dimx,dimy,dimz)) for (i in c(1:dimz)){ print(sprintf('Creating the %d map',i)); Gauslist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } creates 100 GaussMaps (each
2011 Apr 27
1
Eval to write many files
Dear all I am looking for a shorter way and more elegant to write the following for (i in c(1:length(Shadowlist))){ filename<-paste('/home/apa/maps/',model,i,'.mat',sep="") varname<-paste(model,'_shadow',i,sep="") eval(parse(text=paste('writeMat(filename,',varname,'=Shadowlist[[i]])',sep=""))) } actually I do not
2012 Jun 19
1
R and C pointers
Dear R devel, Apologies for these (most probably trivial) questions, doing my first attempt to call C from R (and actually learning C in the process). I need to pass a matrix to C, and after reading R-exts.pdf (many times), I was unable to find how to handle matrices at C-level... except for, what probably is the answer, that matrices are in fact vectors with dimensions. This is a sample code I
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 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
2009 Aug 04
0
Writing a NetCDF file in R
Dear all, I am attempting to convert 10 NetCDF files into a single NetCDF file, due to the data input requirements of a model I hope to use. I am using the ncdf package, version 1.6. The data are global-scale water values, on a monthly basis for 10 years (ie. 120 months of data in total; at present the data are separated by year, with 12 months of data in each file - mrunoff_1986 through to
2009 Aug 05
0
ncdf package problem - put.var.ncdf
Dear all, I am attempting to convert 10 NetCDF files into a single NetCDF file, due to the data input requirements of a model I hope to use. I am using the ncdf package, version 1.6. The data are global-scale water values, on a monthly basis for 10 years (ie. 120 months of data in total; at present the data are separated by year, with 12 months of data in each file - mrunoff_1986 through to
2010 Nov 05
0
NaN, ncdf
Dear All, Can anyone please let me know how exactly ncdf deals with NaN. I am trying to pass in a vector of data that has some NaN in it, into a variable in NetCDF. dimX <- dim.def.ncdf("X","count",(1:6)) dimY <- dim.def.ncdf("Y","count",(1:3)) var1 <-
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
1998 May 29
0
aov design questions
R developers, I have a first attempt to make an aov function. Eventually I want to build in Error() structure, but first I am trying to get this presentable for balanced data with only a single stratum, just using residual error. I am following R. M. Heiberger's Computation for the Analysis of Designed Experiments, Wiley (1989) I a using a wrapper (aov.bal) to call the
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
2006 May 24
2
asterisk amportal start/stopped/start/stopped for all the time
Hi!I've this problem to another asterisk@home machine, without digium cards, but only with a bri isdn card.It doesn't connect in the amportal graphical,(it's stopped), if I make tha amportal start command this is the result: STARTING ASTERISK Asterisk ended with exit status 1 Asterisk died with code 1. Automatically restarting Asterisk. Asterisk ended with exit status 1 Asterisk died
2012 Feb 02
1
"shifted" bar chart / battleship curve
What I want to do is create a horizontal bar chart matrix for a set of data that have a common set of variables (e.g., % of As, % of Bs, etc.) listed on the Y-axis and groups (e.g., Classes) on the X-axis. The key here is that the bars for each individual class plot are "centered" rather than left or right-justified. In archaeology plots similar to this are called battleship curves or
2012 Apr 27
3
kiteChart to show real values with scalebar
Dear R-users I hope someone could help me on this problem. I want to create a multiple kiteChart showing the real values with a scalebar on each indicating the scale . Here are some sample data to show what I want to achieve. Y <- read.table(textConnection("Sample1 Sample2 60 20 150 50 300
2011 Apr 14
4
Categorical bubble plot
Hi, I do not have much R experience just the basics, so please excuse any obvious questions. I would like to create bubble plot that have Categorical data on the x and y axis and then the diameter if the bubble the value related to x and y. Attached to the email is a pic of what I would like to do. I do hope someone can help me. -- Regards/Groete/Mit freundlichen Gr??en/recuerdos/meilleures
2010 May 28
4
Matrix interesting question!
hi, I have been trying to do this in R (have implemented it in Excel) but I have been using a very inefficent way (loops etc.). I have matrix A (columns are years and ages are rows) and matrix B (columns are birth yrs and rows are ages) I would like to first turn matrix A into matrix B And then I would like to convert matrix B back again to the original matrix A. (I have left out details of
2009 Apr 28
1
latticeExtra: useOuterStrips and axis.line$lwd
Hi, I'm working on some lattice wireframe figures that have two conditioning factors, and I want the strips labelled on the top and left of the entire plot, rather than above each individual panel. useOuterStrips() does this, but it draws internal axis lines, even after I explicitly set axis.line to 0. Is there a way to use useOuterStrips but without axis boxes? I've included a short
2011 Mar 29
0
Many cores support in R (Multicore Package)
Dear all, I am trying to improve my code for many cores. I have started with multicore package and the function mclapply. A multicore version of the lcapply. One problem I have is that when I use this function (you can copy and paste the below) require('multicore') returni <-function(i) {i} system.time(mclapply(seq(1:100000),returni)) I get 4 more versions of rkward.bin running (my