
1. Re: R integration:multiple regression analysis
Tracy Rodgers Jan 23, 2014 9:48 AM (in response to Tomomi Otaki)Hi Tomomi,
I'm not familiar enough with R currently to say what the issue with your script is. However, there is a great resource about R that Jonathan Drummey wrote that you can find here:
And a recent solutions page on R Integration that can be found here:
R Integration  Tableau Software
Tracy

2. Re: R integration:multiple regression analysis
Matt Lutton Jan 23, 2014 9:51 AM (in response to Tomomi Otaki) 
3. Re: R integration:multiple regression analysis
Konrad Kwiatek Apr 3, 2015 2:07 PM (in response to Tomomi Otaki)Hi Tomomi,
Have you been able to resolve this problem? I am facing the same issue. Tried several things, but no luck :(
Thanks,
Konrad

4. Re: R integration:multiple regression analysis
Bora Beran Apr 4, 2015 1:44 AM (in response to Konrad Kwiatek)Here is an example workbook that does multiple linear regression
https://www.tableausoftware.com/sites/default/files/blog/r_tableauparameters_0.twbx
This is the issue
(TEST.lm < lm(.arg1~., data=TEST))
You need something like
TEST < data.frame(cbind(a=.arg1, b=.arg2, c=.arg3));
TEST.lm < lm(a~b+c, data=TEST)

5. Re: R integration:multiple regression analysis
Konrad Kwiatek Apr 6, 2015 6:37 AM (in response to Bora Beran)1 of 1 people found this helpfulThanks Bora. I am not R expert and I am not sure what the solution here is. Could you explain what needs to be done?
I am using very simple example using Superstore to make sure the connection with R works.
Here is the formula:
SCRIPT_REAL("
fit < lm(.arg1  .arg2 + .arg3)
fit$fitted"
,
Sum([Profit]),
Avg([Unit Price]),
Avg([Order Quantity])
)
I am getting the following error:
Error in formula.default(object, env = baseenv()) : invalid formula
Appreciate your help,
Konrad

6. Re: R integration:multiple regression analysis
Bora Beran Apr 6, 2015 4:12 PM (in response to Konrad Kwiatek)1 of 1 people found this helpfulThis should work if you fix a minor thing. The issue is
fit < lm(.arg1  .arg2 + .arg3)
should have been
fit < lm(.arg1 ~ .arg2 + .arg3)
assuming you're trying to predict Profit based on unit price and quantity.

7. Re: R integration:multiple regression analysis
Konrad Kwiatek Apr 7, 2015 1:02 PM (in response to Bora Beran)Rookie mistake :) Thanks a lot , Bora. It works now!