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
Well, you can insert `browser()' right above the offending line, then run the code again. It will stop with the `browse>' prompt right before that line. You can then check which value(s) give you the problem. Have you tried Mark Bravington's `debug' package on CRAN? There's an article on it in the most recent issue of R News. Andy> From: Fred J. > > 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 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > >
You also have carriage return as a debug command. I think you are looking for: ?recover Fred J. <phddas <at> yahoo.com> writes: : : 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 : : ______________________________________________ : R-help <at> stat.math.ethz.ch mailing list : https://www.stat.math.ethz.ch/mailman/listinfo/r-help : PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html : :