4 Replies Latest reply on Apr 27, 2017 5:35 PM by Dale Foo

    Return Summary Stats from R to Tableau

    Dale Foo

      Greetings - first post!

       

      I am brand new to R - I'm trying to access and display the summary statistics in Tableau, from a regression in R. The code is following:

       

      SCRIPT_REAL("

        PassFail <- factor(.arg4);

        mydata <- data.frame(cbind(TotalGross=.arg1, Budget=.arg2, PassFail));

        fit <- lm(TotalGross ~ PassFail + Budget, na.action=na.omit, data=mydata);

        return <- summary(fit)$r.squared

        ",

        SUM([Tot Gross]), SUM([Budget]), ATTR([Year]), MAX([Binary])

      )

       

      I understand Tableau can receive either a scalar or replicated vector of length 1, but is there any way I can return all of the summary stats? If I need to retrieve them one by one, as above, won't my model be run each time..?

       

      Many thanks in advance