On 14/12/2012 13:22, Jon Olav Skoien wrote:
Uwe,

I am unfortunately not able to upgrade to R 2.15.2 right now, but I have

Why not? Note that is part of the R-help contract: we only offer any support for the current version of R (see the posting guide).

The posting guide also asked for 'at a minimum' information: we do not know (amongst other things) if this is 32- or 64-bit R. (Your example works for me in both.)

seen a similar problem with several older R versions. If you want to
test with a shorter script, you can try the lines below. These provoke a
crash from a fresh R session on my machine (R 2.15.1 Windows 7):

Rprof()
z = 1
for (i in 1:1e8) z = z+1/i

This runs without problems without the call to Rprof(). I was far from
using all my memory with this call, but you could also check with a
higher number of loops in case you can run these lines and it is somehow
memory related. Just for comparison, I tried 1e9 loops after a call to
Rprof() on one of our Linux servers (R 2.14.0) without any problems.

Which is irrelevant: a different version of R and a completely different implementation of Rprof.


Jon

On 12-Dec-12 17:06, Uwe Ligges wrote:


On 12.12.2012 00:05, Marian Talbert wrote:
I'm trying to use Rprof() to identify bottlenecks and speed up a
particullary
slow section of code which reads in a portion of a tif file and compares
each of the values to values of predictors used for model fitting.  I've
written up an example that anyone can run.  Generally temp would be a
section of a tif read into a data.frame and used later for other
processing.
The first portion which just records the time works in about 6
seconds the
second part causes RGui to immediately close with no error or
warning.  Any
advice on how to get Rprof to work or how to speed up this code would be
greatly appreciated.  I'm using Windows 7 (which might be my problem)
and R
version 2.15.0.

The problem is rather the R version: I cannot reproduce errors with a
recent R.

Uwe Ligges



CalcMESS<-function(tiff.entry,pred.vect){
f<-sum(pred.vect<tiff.entry)/length(pred.vect)*100
               if(is.na(f)) return(NA)
               if(f==0)
return((tiff.entry-min(pred.vect))/(max(pred.vect)-min(pred.vect))*100)
               if(0<f & f<=50) return(2*f)
               if(50<=f & f<100) return(2*(100-f))
               if(f==100)
return((max(pred.vect)-tiff.entry)/(max(pred.vect)-min(pred.vect))*100)
               else return(NA)
}

train.dat <-
data.frame(a=runif(200),b=runif(200),c=runif(200),d=runif(200))
temp <-
data.frame(a=runif(130000),b=runif(130000),c=runif(130000),d=runif(130000))

pred.rng<-temp
vnames.final.mod <- names(train.dat)
nvars.final <- length(vnames.final.mod)

start.time<-Sys.time()
              for(k in 1:nvars.final){

pred.range<-train.dat[,match(vnames.final.mod[k],names(train.dat))]

pred.rng[,k]<-mapply(CalcMESS,tiff.entry=temp[,match(vnames.final.mod[k],names(temp))],MoreArgs=list(pred.vect=pred.range))

                          }
Sys.time()-start.time


Rprof("C:\\temp\\mapply.out")
              for(k in 1:nvars.final){

pred.range<-train.dat[,match(vnames.final.mod[k],names(train.dat))]

pred.rng[,k]<-mapply(CalcMESS,tiff.entry=temp[,match(vnames.final.mod[k],names(temp))],MoreArgs=list(pred.vect=pred.range))

                          }
Rprof(NULL)



--
View this message in context:
http://r.789695.n4.nabble.com/Rprof-causing-R-to-crash-tp4652846.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Brian D. Ripley,                  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to