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

  • Home
  • SEARCH
  • 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 8082957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:17:43+00:00 2026-06-05T17:17:43+00:00

I have a fairly basic data.table in R, with 250k rows and 90 columns.

  • 0

I have a fairly basic data.table in R, with 250k rows and 90 columns. I am trying to key the data.table on one of the columns which is of class character. When I call:

setkey(my.dt,my.column)

I receive the following cryptic error message:

"Error in setkeyv(x, cols, verbose=verbose) :
reorder received irregular lengthed list"

I have found a source-code commit with this message, but can’t quite decipher what it means. My key column contains no NA or blank values, seems perfectly reasonable to look at (it contains stock tickers), and behaves well with the default order() command.

Even more frustrating, the following code completes correctly:

first.dt <- my.dt[1:100000]
setkey(first.dt,my.column)
second.dt <- my.dt[100001:nrow(my.dt]
setkey(second.dt,my.column)

I have no idea what could be going on here. Any tips?

Edit 1: I have confirmed every value in the key fits a fairly standard format:

> length(grep("[A-Z]{3,4}\\.[A-Z]{2}",my.dt$my.column)) == nrow(my.dt)
[1] TRUE

Edit 2: My system info is below (note that I’m actually using Windows 7). I am using data.table version 1.8.

> Sys.info()
          sysname           release           version          nodename           machine             login 
        "Windows" "Server 2008 x64"      "build 7600" "WIN-9RH28AH0CKG"          "x86-64"   "Administrator" 
             user    effective_user 
  "Administrator"   "Administrator" 
  • 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-06-05T17:17:45+00:00Added an answer on June 5, 2026 at 5:17 pm

    Please run :

    sapply(my.dt, length)
    

    I suspect that one or more columns have a different length to the first column, and that’s an invalid data.table. It won’t be one of the first 5 because your .Internal(inspect(my.dt)) (thanks) shows those and they’re ok.

    If so, there is this bug fix in v1.8.1 :

    o rbind() of DT with an irregular list() now recycles the list items
    correctly, #2003. Test added.

    Any chance there’s an rbind() at an earlier point to create my.dt together with an irregular lengthed list? If not, please step through your code running the sapply(my.dt,length) to see where the invalidly lengthed column is being created. Armed with that we can make a work around and also fix the potential bug. Thanks.

    EDIT :

    The original cryptic error message is now improved in v1.8.1, as follows :

    DT = list(a=6:1,b=4:1)
    setattr(DT,"class",c("data.table","data.frame"))
    setkey(DT,a)
    
    Error in setkeyv(x, cols, verbose = verbose) : 
      Column 2 is length 4 which differs from length of column 1 (6). Invalid
      data.table. Check NEWS link at top of ?data.table for latest bug fixes. If
      not already reported and fixed, please report to datatable-help.
    

    NB: This method to create a data.table is not recommended because it lets you create an invalid data.table. Unless, you are really sure the list is regular and you really do need speed (i.e. for speed you want to avoid the checks that as.data.table() and data.table() do), or you need to demonstrate an invalid data.table, as I’m doing here.

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

Sidebar

Related Questions

basic c++ question i'm fairly sure. if i have a base class with a
I have a fairly involved managed data model which has a central object with
I have an ASP.NET application that is fairly basic. It queries some data and
I have a fairly basic question regarding python lists/dictionaries which I would like some
I have a fairly basic TCP server keeping track of a couple connections and
I am making a webapp. I have a fairly basic question about javascript performance.
I have a parent-child relationship setup that is fairly basic. The end result is
I have a Silverlight application that implements some basic CRUD operations on a fairly
I am fairly new to database programming and am trying to get a basic
I have a new MVC 4 Application with a fairly basic View/Controller. The associated

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.