Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4024626
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:44:40+00:00 2026-05-20T10:44:40+00:00

I am trying to use the leaps package. This data frame df has 9

  • 0

I am trying to use the leaps package. This data frame df has 9 columns. Columns 2 through 8 are the explanatory variables and column 9 is the reponse variable. df also has (column) names.

When I try to use the leaps 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 this?

Here is a snippet of the data.frame:

> 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 just to see if it would work, and that didn’t help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:44:41+00:00Added an answer on May 20, 2026 at 10:44 am

    I am not familiar with leaps at all but I could replicate your problem. I think the problem is that one of the variables is either a character or a factor:

    library("leaps")
    df <- data.frame( foo = 1:10, bar = as.factor(1:10), resp = 1:10)
    regsubsets(df[,-3],df[,3])
    

    Gives the error. Note that bar here is a factor:

    sapply(df,is.factor)
      foo   bar  resp 
    FALSE  TRUE FALSE 
    

    Coercing to numeric the error is gone:

    df$bar <- as.numeric(as.character(df$bar))
    regsubsets(df[,-3],df[,3])
    

    This gives other warnings but that is probably due to the silly dataset

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am need paint my image. I'm trying use JQuery in here this link:
I'm trying to use fixtures as a DB-agnostic way to get the data into
I'm trying to use ActiveRecord's find_or_create_by_*column* , but I'm getting errors from Postgres letting
I'm trying to use this php script in order to locate a stock quote
i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying use gem tire to search in my application. I have tables
I was trying use a set of filter functions to run the appropriate routine,
I'm trying use self-signed certificate (c#): X509Certificate2 cert = new X509Certificate2( Server.MapPath(~/App_Data/myhost.pfx), pass); on
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use a Java Uploader in a ROR app (for its ease

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.