[R] finding warning point in function

Gabor Grothendieck ggrothendieck at gmail.com
Sun Mar 12 20:19:23 CET 2006


If your function is called f then

options(warn = 2)
debug(f)

will cause the warning to be converted to an error and when
the error stops the code just issue:

traceback()


On 3/12/06, Federico Calboli <f.calboli at imperial.ac.uk> wrote:
> Hi everyone,
>
> I would like to find out when and where exactly I get the following
> warning in a piece of code I've written:
>
> Error in "[<-"(`*tmp*`, iseq, value = numeric(0)) :
>        nothing to replace with
>
> The code is a for () loop performing a somewhat trivial calculation,
> modulated by a number of logical if(){} else(){} conditions, involving
> the creation of a number of vectors that contain the elements that will
> be manipulated.
>
> The warning itself makes me suspicious that somewhere along the way a
> vector ends up having length 0 for some of the elements of my dataset...
> is there a way of finding out where the warning is generated that is
> less verbose than printing out every single step?
>
> Cheers,
>
> Federico
>
>
> --
> Federico C. F. Calboli
> Department of Epidemiology and Public Health
> Imperial College, St Mary's Campus
> Norfolk Place, London W2 1PG
>
> Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193
>
> f.calboli [.a.t] imperial.ac.uk
> f.calboli [.a.t] gmail.com
>
> ______________________________________________
> 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
>




More information about the R-help mailing list