Yes. This is in fact very easy. SCRIPT_ functions are table calculations and Tableau will call the function once for each partition in your dataset.
So if you click on the pill that contains this function and select Edit Table Calculation and go to Advanced... setting in the compute using drop down and make sure Patient Type is in the box that says Partitioning, you should get the results you're looking for.
Thanks a lot Bora, that seemed to work. Another quick question if I may. I would like to export the results, ie coefficients, standard errors and odds ratios from my logistic regression to some format such as excel but I haven't been able to find a way to do it correctly. There is some sort of summary and write function but the syntax and how to call these functions in Tableau seems to escape me. Here's my regression script below, was hoping you could add in the necessary bits and tell me how to call these procedures since Tableau doesn't really have an R command line to do it. We can just call the results table "results.csv" or something and export it to the root of my C Drive.
admitstatus <- .arg1
age <- as.factor(.arg2)
triagecode <- as.factor(.arg3)
cci_score <- .arg4
gender <- as.factor(.arg5)
fit <- glm(admitstatus ~ age + triagecode + cci_score + gender,family = binomial(logit))
prob <- predict(fit,type = 'response')
avg([Admit Status] ),attr([Age Group]),attr([Triagecode]), avg([Cci Score Without Age]), ATTR([Gender])