We’ve extended Inspire Early Bird Pricing until March 1. Register now and enjoy 20% off conference passes and 10% off training passes. P.S. Don’t forget to bring friends! When you sign up for five or more tickets, you get an extra 20% discount on conference passes. Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Radio buttons not working with R_Tool

10 - Fireball



I'm trying to mimic the count_regression radio function for my own r_tool based GLM.  Below I have the code and a picture of the radio buttons.  I copied the text from the count_regression but for some reason, my code does not recognize this.  Any thoughts on what I'm doing wrong?


#get distribution from questions.


if (!is.XDF) {
if ('%Question.quasipoisson%' == "True")
the_family <- "quasipoisson(link='log')"
if ('%Question.gamma%' == "True")
the_family <- "gamma(link='log')"
if ('%Question.tweedie%' == "True")
the_family <- "tweedie(var.power=1.5,link.power=0)"
} else {
the_family <- "quasipoisson(link='log')"

# Run the model


piecewise2 <- glm(the_form, control = glm_control, weights = eufactor, family = the_family, data = the_data3)




Hi @jbh1128d1


When you copied the radio button, did you change the name of the radio button back to "quasipoisson" in the annotations menu? When you copy and paste a radio button it is renamed to Radio Button (tool id).




If named correctly, you should see the Question in the Workflow Constants:




10 - Fireball

Hey @JeffF.  This was also taken care by @DrDan.  See his reply below:  (If @DrDan would like to re-post that answer to this, I'll mark it as a solution).  




When you are working with a GUI elements, you get to write a lot of R code that works by parsing and evaluating strings. The problem in this particular case is in dealing with the family argument to glm, which wants to be passed family function object, and you are providing it with a character vector object ("the_family") instead. This is how you solve the problem:


piecewise2 <- eval(parse(text = paste0("glm(the_form, control = glm_control, weights = eufactor, family = ", the_family, ", data = the_data3)")))

 In this case, within the text string, what is in put in is not "the_family", but your actual argument (say quasipoisson(link='log'), so the string becomes


"glm(the_form, control = glm_control, weights = eufactor, family = quasipoisson(link='log'), data = the_data3)

 When this string is parsed and evaluated, you will get the model you were hoping to get.



Alteryx Alumni (Retired)



Rather than re-post my comment to you (since you've included it here already), let me provide a link to the original Knowledge Base article: Guide to Creating Your Own R-Based Macro - Create and Test a Basic Macro.