[R] J48 - contrasts can be applied only to factors with 2 or more levels

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Feb 26 19:28:16 CET 2011



On 24.02.2011 15:29, Patrick Skorupka wrote:
> Hi everybody,
>
> I recently sent out a first message using this tool and was astonished about the quick and helpful replys. So, thank you in advance for your help, I really appreciate that!
>
> As already recently mentioned I am new to using R as I have to implement some decision trees with R respectively RWeka for my master thesis. I have tried so built some J48 trees and could accomplish first, very basic results. But when I increased the number of independent variables the tree in fact is getting created, but when I try to plot it, R displays “Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :  contrasts can be applied only to factors with 2 or more levels€.
>
> I found out that this was apparently due to IVs with only one value and so excluded all these variables from the dataset and double-checked it by using the summary function. Anyway the same error occurs. Anyone any idea? Is there a specific function to test my dataset in this way instead of doing it manually or with the summary function? FYI, the dataset contains 54 attributes, all kind of scales and about 5,000 rows.
>
>

You may want to supply a reproducible example of that behaviour as the 
posting guide asks you to do.

Best,
Uwe Ligges



More information about the R-help mailing list