Warning message: In xtfrm.data.frame(x) : cannot xtfrm data frames

Hello everyone, I am a bit confused.

I need to change column two in my data set to a factor (see upload for dataset):

2021HelicopterPlanWithResponseData.pdf (44.1 KB)

When I use:
hdata[,2] <- as.factor(hdata[,2])

I get this warning:
Warning message:
In xtfrm.data.frame(x) : cannot xtfrm data frames

However, when I use:
wing.length = as.factor(hdata$Wing.Length)

It creates the factor I need.

My professor gave us the first code that gets the warning. He said we need to use that code so that R will treat column two as a factor.

Is the wing. length code the same as the hdata[,2]? Or does the hdata[,2] change the data frame when the wing.length code does not? Is there another way to get around the original error?

Some changes to newer versions of R could have broken that code. Try

wing.length = as.factor(hdata$Wing.Length)
hdata$Wing.Length.New = wing.length

Then alter code following that references hdata[,2] to reference hdata[,4], or any code referencing hdata$Wing.Length to hdata$Wing.Length.New.

This may get you by.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.