2
#2개년(use: df_3 , MSE: 0.02313121)
 #선형회귀모델
 lm2 <- lm(data = df_3, formula = OPS_y1 ~ (OPS_y2+OPS_y3 + AVG_y2+AVG_y3 + G_y2+G_y3 + GW.RBI_y2+GW.RBI_y3 + H_y2+H_y3  + SAC_y2+SAC_y3)^2) %>% step(direction = "both")

Error in length(obj) : class name too long in 'length'

Once the code has been executed, it will be executed normally. However, if you change the data set and run it again, the same error occurs when you run the first code again. What's the problem? I went to the registry editing window and changed the value of 'LongPathsEnabled' to 1, but it was not resolved. Please solve the problem.

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
sonbar
  • 21
  • 1
  • 2
  • 1
    Please add a sample of your data with `dput`. Also if possible, please translate the comments to English. More details available [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Thanks! – NelsonGon Mar 25 '19 at 16:58
  • I didn't solve it. There is still an error. – sonbar Mar 25 '19 at 17:44
  • I solved the problem by simply shortening Formula's ceremony. The ceremony must have been too long....Now that we can't use step(), we need to create a variable combination every day. – sonbar Mar 25 '19 at 18:17

2 Answers2

4

I had the sample problem when using stepwise regression with the step function. In my case there was some package conflict and all was fine after I specified stats::step(...) as follows:

lm2 <- lm(data = df_3, formula = OPS_y1 ~ (OPS_y2+OPS_y3 + AVG_y2+AVG_y3 + G_y2+G_y3 + GW.RBI_y2+GW.RBI_y3 + H_y2+H_y3  + SAC_y2+SAC_y3)^2) %>% stats::step(direction = "both")
user12282991
  • 41
  • 1
  • 2
  • it would be really useful if you could run `find("step")` to see which package the conflict is coming from ... – Ben Bolker Oct 27 '19 at 21:34
4

As pointed out by user12282991, the problem may be due to package conflicts. The error most probably results from attaching the package recipes, which masks "step" from package:stats. Thus, stepAIC from package MASS or stats::step works.

library(recipes)
step(subclass = paste(rep("A",1000),collapse=""))

gives Error in (function (x, ...) : class name too long in 'print'.

Ganain
  • 41
  • 1