2 Replies Latest reply on Mar 23, 2016 11:47 AM by Bora Beran

    Export GLM Regression Results to CSV File

    Ed Kukec

      Hi All,

       

      I've recently started using R Integration in Tableau and I'm really liking it.  As you can see in the sample below...I've done a pretty simple Logistical Regression Model that computes the probabilty of an Inpatient Admission (Dependant Variable) from the Emergency Department given a person's Age (Predicator) and Triage Code (Predictor).  The model is working fine but I would like to save the coefficients, ie intercept, slope, etc. into some type of data file such as a CSV or Text File and if possible save the regression coefficients, slope and intercept into variables that I can access in tableau.  Is this possible?  Here's my code:

       

      SCRIPT_REAL("

      admitstatus     <- .arg1

      age                 <- .arg2

      triagecode      <- .arg3

       

      fit <- glm(admitstatus ~ age + triagecode,family = binomial(logit))

      fit$fitted

      ",

      ATTR([Admit Status] ),ATTR([Age Admit]),Attr([Triagecode])

      )

       

      Thanks,

      Ed