1

Referring to the this link Prediction In Tableau I am making a logistic regression model in Tableau using R script.
Every time i get the error

Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels

Need to build a nested calculation in tableau but not sure what is the hierarchy tableau follow. Need to give users a filter which they can select and see the probability of purchase.
Attached is the sample workbook as well.

Shivi Bhatia
  • 157
  • 4
  • 22
  • Reports of errors need data (your data or data that allows us to reproduce the error) and code to support them. Just posting an error message is almost never enough. – IRTFM Mar 25 '18 at 00:43
  • Please find the link for the twbx file https://drive.google.com/open?id=14HS7zqz1gPRHyJmeMKci3iCFio5SQT1n – Shivi Bhatia Mar 25 '18 at 07:13
  • Those of us R users have no way to determine what sort of code you are throwing at the R engine. I can open that file and use my text editor to view the workbook code because it is an xml file inside. But it's big and I have no idea where to look in it if it indeed contains the r code. – IRTFM Mar 25 '18 at 17:39
  • 1
    This is not a duplicate of the questions above, as there is no factor in my data which has a single category. the code used is `dat <- na.omit(aa)`. Here aa is the CSV i had read. ## extract factor columns and drop redundant levels `fctr <- lapply(dat[sapply(dat, is.factor)], droplevels)` ## count levels `sapply(fctr, nlevels)`. The result of sapply is TV_NTV_CATEGORY NEW_CAR_MODEL DEALER_ZONE SERVICE_TYPE GENDER OCCUPATION 2 14 5 17 2 29 – Shivi Bhatia Mar 26 '18 at 07:31
  • Sometimes there are procedures that do subsetting of data before passing to glm(...) which is the underlying logistic regression function. The subsetting may create a data-object that has only one level of a factor. – IRTFM Mar 26 '18 at 15:01
  • If you want better R help you may need to produce a copy of the data in a form that non-license holders of Tableau can work on. Your question is a) not-reproducible and b) based on a commercial software product that is no available to most of us R-users. – IRTFM Mar 26 '18 at 15:08

0 Answers0