[R] contrasts can be applied only to factors with 2 or more levels
Patrick (Malone Quantitative)
m@|one @end|ng |rom m@|onequ@nt|t@t|ve@com
Fri Dec 20 22:20:34 CET 2019
As the Posting Guide directs, please make all replies to the list.
Basically, you need to inspect your data. Using "~ ." adds everything
in the dataframe that's not elsewhere in the function as predictors.
Check the descriptive statistics on every one (variance/standard
deviation for numeric data, table for string/factor).
On Fri, Dec 20, 2019 at 3:32 PM javed khan <javedbtk111 using gmail.com> wrote:
> Hi Patrick
> I have no idea about this type of error. Is it a categorical predictor? How to find variability?
> On Fri, Dec 20, 2019 at 9:08 PM Patrick (Malone Quantitative) <malone using malonequantitative.com> wrote:
>> Seems self-explanatory. It sounds like one of your predictors has no
>> On Fri, Dec 20, 2019 at 3:01 PM javed khan <javedbtk111 using gmail.com> wrote:
>> > I am using the folowing code and it give me the error message like
>> > " contrasts can be applied only to factors with 2 or more levels".
>> > What could be the problem
>> > d=read.csv("Result.csv")
>> > index <- createDataPartition(log10(d$Results), p = .70,list = FALSE)
>> > tr <- d[index, ]
>> > ts <- d[-index, ]
>> > index_2 <- createFolds(log10(tr$Results), returnTrain = TRUE, list = TRUE)
>> > ctrl <- trainControl(method = "cv", index = index_2)
>> > set.seed(30218)
>> > grid_search <- train(log10(Results) ~ ., data = tr,
>> > method = "svmRadial",
>> > tuneLength = 8,
>> > metric = "MAE",
>> > preProc = c("center", "scale", "zv"),
>> > trControl = ctrl)
>> > [[alternative HTML version deleted]]
>> > ______________________________________________
>> > R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
More information about the R-help