Hello, What options are available for me to debug my R scripts? For example I normally do something like>source("myfunctions.R") >function1("height", "weight")myfunctions.R is a large R source file that contains many functions. function1 is the "main" function in myfunctions.R. It calls many other user-written functions that are also in myfunctions.R. I only want to debug the R scripts. I do not need to get into the code of R itself. I would like to be able to: - see the source as I am debugging - execute line-by-line - see and modify variables - have the option to either descend into function calls, or not - have the option to either descend into loops, or not Maybe this is asking too much but I thought I would lay out my dreams and then you can tell me what is really possible. Thanks, Larry Howe
On Monday April 17 2006 19:45, Larry Howe wrote:> Hello, > > What options are available for me to debug my R scripts? For example I > normally do something like > > >source("myfunctions.R") > >function1("height", "weight") > > myfunctions.R is a large R source file that contains many functions. > function1 is the "main" function in myfunctions.R. It calls many other > user-written functions that are also in myfunctions.R. > > I only want to debug the R scripts. I do not need to get into the code of R > itself. I would like to be able to: > > - see the source as I am debugging > - execute line-by-line > - see and modify variables > - have the option to either descend into function calls, or not > - have the option to either descend into loops, or not > > Maybe this is asking too much but I thought I would lay out my dreams and > then you can tell me what is really possible.Forgot to mention: I am working in linux and solaris. Other people here are working in windows. So I am interested in options for either platform.
RSiteSearch("debug") or RSiteSearch("debugging") will give you a lot or relevant information. I personally use library(debug) extensivelly and it should do all the taks you asked about. There is a nice article describing the debug lilbrary in the 2003/3 issue of R News http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf Cheers Francisco>From: Larry Howe <larry.howe at comjet.com> >To: r-help at stat.math.ethz.ch >Subject: Re: [R] R debugging options >Date: Mon, 17 Apr 2006 20:29:47 -0400 > >On Monday April 17 2006 19:45, Larry Howe wrote: > > Hello, > > > > What options are available for me to debug my R scripts? For example I > > normally do something like > > > > >source("myfunctions.R") > > >function1("height", "weight") > > > > myfunctions.R is a large R source file that contains many functions. > > function1 is the "main" function in myfunctions.R. It calls many other > > user-written functions that are also in myfunctions.R. > > > > I only want to debug the R scripts. I do not need to get into the code >of R > > itself. I would like to be able to: > > > > - see the source as I am debugging > > - execute line-by-line > > - see and modify variables > > - have the option to either descend into function calls, or not > > - have the option to either descend into loops, or not > > > > Maybe this is asking too much but I thought I would lay out my dreams >and > > then you can tell me what is really possible. > >Forgot to mention: I am working in linux and solaris. Other people here are >working in windows. So I am interested in options for either platform. > >______________________________________________ >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
On 4/17/2006 7:45 PM, Larry Howe wrote:> Hello, > > What options are available for me to debug my R scripts? For example I > normally do something like > >> source("myfunctions.R") >> function1("height", "weight") > > myfunctions.R is a large R source file that contains many functions. function1 > is the "main" function in myfunctions.R. It calls many other user-written > functions that are also in myfunctions.R. > > I only want to debug the R scripts. I do not need to get into the code of R > itself. I would like to be able to: > > - see the source as I am debugging > - execute line-by-line > - see and modify variables > - have the option to either descend into function calls, or not > - have the option to either descend into loops, or not > > Maybe this is asking too much but I thought I would lay out my dreams and then > you can tell me what is really possible.You can do some of that using the debug() and browser() functions. They aren't exactly source-level debuggers: they work by showing you deparsed versions of the code. Since these aren't source oriented, you don't have the usual "descend" option. You set a flag on a function, and enter the debugger whenever that function is called. Mark Bravington's debug package goes a bit further towards a true source-level debugger. The soon-to-be-released 2.3.0 has information on debugging in the R Extensions manual. I don't think it's online yet other than as part of the beta versions. You can also see some mainly Windows oriented material on my web page, http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/. Duncan Murdoch
On Monday April 17 2006 21:08, Francisco J. Zagmutt wrote:> RSiteSearch("debug") or RSiteSearch("debugging") will give you a lot or > relevant information. I personally use library(debug) extensivelly and it > should do all the taks you asked about. There is a nice article describing > the debug lilbrary in the 2003/3 issue of R News > http://cran.r-project.org/doc/Rnews/Rnews_2003-3.pdf > > Cheers > > FranciscoWow! That is a great package. I think it does all I need. Is there a way to turn on debugging for all loaded functions? My source file contains many functions and I would prefer not to have to mtrace() each one. Something like>mtrace(how_do_I_get_a_list_of_all_loaded_functions)? Larry