I am trying to use a package leaps
. This data frame df
has 9 columns. Columns 2 through 8 are explanatory variables, and column 9 is the response variable. df
also has (columns) names.
When I try to use the jump package, I get a cryptic error.
x <- df[,2:8]
y <- df[,9]
leaps <- regsubsets(x, y)
Error in leaps.setup(x, y, wt = weights, nbest = nbest, nvmax = nvmax, :
character variables must be duplicated in .C/.Fortran
What does this error mean, and how can I prevent it?
Here is a fragment of the data.frame file:
> dput(df[1:2,])
structure(list(Var1 = c(2396, 2396), Var2 = c(NA_character_,
NA_character_), Var3 = c(NA_character_, NA_character_), Var4 = c(501,
511), Var5 = c(5, 5), Var6 = c(13, 8), Var7 = c(NA_real_, NA_real_
), Var8 = c(NA_real_, NA_real_), Var9 = c(0.0047, 0.0371)), .Names = c("Var1",
"Var2", "Var3", "Var4", "Var5", "Var6", "Var7", "Var8", "Var9"
), row.names = 1:2, class = "data.frame")
> str(df)
'data.frame': 10000 obs. of 9 variables:
$ Var1: num 2396 2396 2396 2396 2396 ...
$ Var2: chr NA NA NA NA ...
$ Var3: chr NA NA NA NA ...
$ Var4: num 501 511 523 757 770 803 803 803 807 506 ...
$ Var5: num 5 5 3 5 1 1 5 5 5 5 ...
$ Var6: num 13 8 13 11 13 8 13 8 11 11 ...
$ Var7: num NA NA NA NA NA NA NA NA NA NA ...
$ Var8: num NA NA NA NA NA NA NA NA NA NA ...
$ Var9: num 0.0047 0.0371 0.042 0.0488 0.0048 ...
I tried replacing the missing values with 0 to see if this would work, and that didn't help.