[R] sapply and loop

Petr Pikal petr.pikal at precheza.cz
Wed Oct 20 09:05:13 CEST 2004



On 19 Oct 2004 at 14:49, Zhen Pang wrote:

> I am sorry for neglecting the acknowledgement for `Writing R
> Extensions', since I think I am just citing the code from the orignal
> R-help. I fail to get the results when I use my own code. So I refer
> to this code where Rprof() appears. Anyway, I am sorry for this.
> 
> In fact, I have tried to whether I specify boot.out. Neither one
> works.
> 
> Rprof("boot.out")
>      storm.boot <- boot(rs, storm.bf, R = 4999) # pretty slow
>       Rprof(NULL)
> 
> summaryRprof()
> Error in summaryRprof() : no events were recorded
> 
> summaryRprof("boot.out")
> Error in summaryRprof("boot.out") : no events were recorded

Hi

works for me without any problems. So you have probably 
mismatch in your directories (where is file boot.out?, is it in your 
working directory?)

Cheers
Petr



> 
>      Rprof()
>      storm.boot <- boot(rs, storm.bf, R = 4999) # pretty slow
>       Rprof(NULL)
> 
> summaryRprof()
> Error in summaryRprof() : no events were recorded
> 
> 
> Zhen
> 
> 
> >From: Prof Brian Ripley <ripley at stats.ox.ac.uk>
> >To: Zhen Pang <nusbj at hotmail.com>
> >CC: tlumley at u.washington.edu, r-help at stat.math.ethz.ch
> >Subject: Re: [R] sapply and loop
> >Date: Tue, 19 Oct 2004 07:29:54 +0100 (BST)
> >
> >On Tue, 19 Oct 2004, Zhen Pang wrote:
> >
> > > I tried to use Rprof(). As an example, I consider the following
> > > code 
> >(from
> > > Venables & Ripley, 1999).
> >
> >I believe you parroted that from `Writing R Extensions', but failed
> >to give proper credit!
> >
> > >      library(MASS); library(boot); library(nls)
> > >      data(stormer)
> > >      storm.fm <- nls(Time ~ b*Viscosity/(Wt - c), stormer,
> > >                      start = c(b=29.401, c=2.2183))
> > >      st <- cbind(stormer, fit=fitted(storm.fm))
> > >      storm.bf <- function(rs, i) {
> > >          st$Time <-  st$fit + rs[i]
> > >          tmp <- nls(Time ~ (b * Viscosity)/(Wt - c), st,
> > >                     start = coef(storm.fm))
> > >          tmp$m$getAllPars()
> > >      }
> > >      rs <- scale(resid(storm.fm), scale = FALSE) # remove the mean
> > >      Rprof("boot.out") storm.boot <- boot(rs, storm.bf, R = 4999)
> > >      # pretty slow Rprof(NULL)
> >
> >At this point your unacknowledged copying went adrift.
> >
> > > summaryRprof()
> > > Error in summaryRprof() : no events were recorded
> > >
> > > I am using R1.8.1 in windows. Why can't I get the results?
> >
> >Because you didn't do your homework, and didn't even follow your
> >source. The 'file' arguments of Rprof and summaryProf have to agree:
> >see their help pages (as the posting guide asks).
> >
> >--
> >Brian D. Ripley,                  ripley at 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 at stat.math.ethz.ch mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide! 
> >http://www.R-project.org/posting-guide.html
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list