Alteryx Designer Desktop Discussions

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

Question: Can a string from an select tool be put in as an object in the R Tool Inputs

jbh1128d1
10 - Fireball

Is it possible to read in a string into the r tool and use it as a formula?  

 

For example, if I take a workflow that produces an r formula in a string format (i.e. glm(freq ~ marriage + state + age + length)) and put that into an r tool input, can I then read that into r and use that as a formula?  Currently the code is as follows but not yielding results I want: 

 

#run the spline model
spline <- read.Alteryx("#2", mode = "list")
fit <- glm(as.formula(spline), family = quasipoisson(link="log"), data = the_data )

  string.JPG

2 REPLIES 2
TonyM
Alteryx Alumni (Retired)

Hi @jbh1128d1

 

It sounds like you're in need of a batch macro! By wrapping the R tool in a macro you could pass the r formula string to the R code via a control parameter. Using the control parameter of a batch macro is a great way to pass dynamically changing information into any tool in the alteryx palette. 

 

Apps and Macros

Batch Macro

Control Parameter

 

Let me know if this helps!

jbh1128d1
10 - Fireball

Thanks Tony. It that didn't yield great results either. I did figure out how to bring in the string by pulling in the output as a data.frame then pulling the string out as a value itself and code it as a as.formula to use. Essentially I copied the method used in the out of the box count regression tool. 

 

I appreciate the reply. 

Labels