Hello,
I'm trying to use a radio button to update the distribution of my piece wise linear regression macro. I copied the glm tool macro language to pull in the distribution of the glm as such:
is.XDF <- FALSE if (!is.XDF) { if ('%Question.Quasipoisson%' == "True") the.family <- "quasipoisson(link='log')" if ('%Question.Gamma%' == "True") the.family <- "gamma(link='log')" } else { the.family <- "quasipoisson(link='log')" } # Create a string of the potential predictors seperated by plus signs the_preds <- paste(names(the_data)[-1], collapse = " + ") # Get the name of the target field the_target <- names(the_data)[1] # Create a formula expression from the names of the target and predictors the_form <- as.formula(paste(the_target, the_preds, sep = " ~ ")) # Run the model fit1 <- glm(the_form, "family = " the.family , data = the_data) #
And I do not have the radio buttons connected to anything (like the count regression tool has it set up):
I'm not sure why the code is not working. The error I get is unexpected symbol in "fit1 <- glm(the_form, "family =" the.family
Solved! Go to Solution.
If you added those radio button yourself, my guess is that you didn't update the tool name, and not referring to the question to be displayed.
Click on the radio button and in the configuration screen, select the "Annotation" icon. Name this to what you'll want to use in your R script.
This is the value that you'd use in '%Question.<ToolName>%'.
Hope this helps!
Thank you @jrgo. Worked like a charm.