It took me a longgggg time to figure out a reasonably efficient way to test and debug my code for a menu using deducer. In case this is useful to others I am pasting a simple example below. If you source this code from the JGR console (with Deducer loaded) you get the dialog to pop-up and can test if the code is working as expected. If not, make changes to the code and source again, and again, and again, as needed. If there are other, perhaps more effective, ways to debug I'd luv to hear about them.
.olsCheckFunction <- function(state) { if(length(state$dep) < 1) return("Please select a dependent variable") if(length(state$indep) < 1) return("Please select at least one independent variable") return("")
}
.olsRunFunction <- function(state) {
form <-paste( " ~ " , state$indep[1]) for(var in state$indep[-1]) form <- paste(form,"+",var)
I guess the title of my post might be a bit misleading. I am not suggesting my way 'is' the best way to debug your deducer code :) I should have added a '?', i.e., 'how best to debug dialog and run code?'
On Tuesday, November 13, 2012 1:46:47 AM UTC-8, Vincent wrote:
> It took me a longgggg time to figure out a reasonably efficient way to > test and debug my code for a menu using deducer. In case this is useful to > others I am pasting a simple example below. If you source this code from > the JGR console (with Deducer loaded) you get the dialog to pop-up and can > test if the code is working as expected. If not, make changes to the code > and source again, and again, and again, as needed. If there are other, > perhaps more effective, ways to debug I'd luv to hear about them.
> .olsCheckFunction <- function(state) { > if(length(state$dep) < 1) > return("Please select a dependent variable") > if(length(state$indep) < 1) > return("Please select at least one independent variable") > return("") > }
> .olsRunFunction <- function(state) {
> form <-paste( " ~ " , state$indep[1]) > for(var in state$indep[-1]) > form <- paste(form,"+",var)
That is pretty much correct. It should be said that programming in
general has a large component of
bang-head-on-table-why-won't-this-work to it, especially when you are
starting out. One thing that is useful is to print out things with the
cat function.
Debugging dialogs in R is actually quite a bit easier than in Java, as
there is no need to recompile or reinstall a package.
On Tue, Nov 13, 2012 at 2:11 PM, Vincent <vincent.n...@gmail.com> wrote:
> I guess the title of my post might be a bit misleading. I am not suggesting
> my way 'is' the best way to debug your deducer code :) I should have added a
> '?', i.e., 'how best to debug dialog and run code?'
> On Tuesday, November 13, 2012 1:46:47 AM UTC-8, Vincent wrote:
>> It took me a longgggg time to figure out a reasonably efficient way to
>> test and debug my code for a menu using deducer. In case this is useful to
>> others I am pasting a simple example below. If you source this code from the
>> JGR console (with Deducer loaded) you get the dialog to pop-up and can test
>> if the code is working as expected. If not, make changes to the code and
>> source again, and again, and again, as needed. If there are other, perhaps
>> more effective, ways to debug I'd luv to hear about them.
>> .olsCheckFunction <- function(state) {
>> if(length(state$dep) < 1)
>> return("Please select a dependent variable")
>> if(length(state$indep) < 1)
>> return("Please select at least one independent variable")
>> return("")
>> }
>> .olsRunFunction <- function(state) {
>> form <-paste( " ~ " , state$indep[1])
>> for(var in state$indep[-1])
>> form <- paste(form,"+",var)