[R] debugging a code

Fred J. phddas at yahoo.com
Thu Mar 25 00:25:25 CET 2004


Hello
just learned HowTo but R, reminded me with the way
Perl does it but with much less on-line commands, R
"AFAIK" has n, c, Q and where and cann't debug outside
the {}. 

1) is there a more versatile/flexable debugging method
for R?

I have saved 2 functions in an ASCII file "digfun".
"getdata" function calls "squash" function and both
use loops. In another file.R I have

source("digfun")
debug(getdata)
data <- getdata("c:/data/")

Browse[1]> c
Error in if (d[i, "V3"] == d[i + 1, "V3"] && d[i,
"V4"] == d[i + 1, "V4"] &&  : 
	missing value where TRUE/FALSE needed
> traceback()
2: squash(dt1)
1: getdata("c:/data/")
> 
to dubug this I need to know the value of some
variable at this particular loop/sub-fun loop case,
and since the dubuger terminated by showing ">"
prompt, how then I am going to debug this error?

thanks for helping




More information about the R-help mailing list