0

I am trying to perform forward selection for my data frame which I encountered some issues which I think there may be alternatives for it.

I will first show you my code on it:

#library(tidyverse)
library(caret)
library(leaps)
library(MASS)

XBC <- read.csv("path/to/my/file/file.csv")

XBC <- XBC[ -c(1:3) ]
full.model <- lm(Treatment~., data = XBC)
# Stepwise regression model
step.model <- step(full.model, direction = "forward", scope = formula(full.model))

This is the error I kept receiving:

full.model <- lm(Treatment~., data = XBC)

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : NA/NaN/Inf in 'y' In addition: Warning message: In storage.mode(v) <- "double" : NAs introduced by coercion

As I know the reason why this error occurs was because the data in the column Treatment are characters which are the different treatment groups that I have.

Is there any alternative for me to do a forward selection for this Treatment group that I have as they are characters.

Link to dataframe

UseR10085
  • 7,120
  • 3
  • 24
  • 54
Calvin Chow
  • 31
  • 1
  • 4

0 Answers0