I'm creating a macro in which I have an R script node that is running a simple linear regression model. Yes, I know linear regression is available as a tool - I'm trying to stick with something simple here to scale up for other processes. Most of my R processes I need to select a single target and an unknown amount of predictor variables. Essentially I need to partially mimic the configuration window in the Linear Regression tool. I have dissected the macro of the linear regression tool but the predictor selection is throwing me off.
My R Script is simple:
data <- read.Alteryx("#1", mode="data.frame")
RGR <- lm(Target ~ IV1+IV2+IV3, data = data)
I have been successful in replacing "Target" with an Action where I have the action replace the string "Target" but I can't figure out how to replace IV1:3 dynamically. If in the future I have 8 variables instead of 3 that I'm using I need to replace "IV1+IV2+IV3" with "IV1+IV2+IV3+IV4+IV5+IV6+IV7+IV8" and so forth.
It seems like from the linear regression macro that I need to do something with XML (which I'm unfamiliar with) If anyone has any input on how to accomplish this with an action, I'd be eternally grateful!
Thanks!