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 8746453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:11:44+00:00 2026-06-13T12:11:44+00:00

I had asked this question earlier and thought I might post an example that

  • 0

I had asked this question earlier and thought I might post an example that shows why I was seeing the effect, in the event that it might be helpful:

require(data.table)
x <- data.table(a=1:10)
x[,a:=scale(a)]
#    [,1]      
# 1: -1.4863011
# 2: -1.1560120
# 3: -0.8257228
# 4: -0.4954337
# 5: -0.1651446
# 6:  0.1651446
# 7:  0.4954337
# 8:  0.8257228
# 9:  1.1560120
#10:  1.4863011
na.omit(x)
Error in `[.data.table`(object, !omit) : 
  i is invalid type (matrix). Perhaps in future a 2 column matrix could return a list     of elements of DT (in the spirit of A[B] in FAQ 2.14). Please let datatable-help know if     you'd like this, or add your comments to FR #1611.

The reason seems to be that scale does not return a vector and data.table did not complain. Doing x[,a:=as.vector(scale(a))] instead appears to fix the issue. Have I missed something in the documentation?

  • 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-13T12:11:45+00:00Added an answer on June 13, 2026 at 12:11 pm

    Good question (I edited slightly). It should either be a warning, or data.table could coerce the 1 column matrix to a vector automatically, since I guess scale in the way you showed is a common task and natural to do like that. The na.omit aspect is one way of revealing the issue, but there are probably other ways since the root cause is further up as you nicely showed.

    Bug report filed, thanks :

    Bug#2333 := is able to create a “matrix” column, but “matrix” columns are invalid


    Update: Root cause is now fixed in v1.8.3. A 1 column matrix is silently treated as vector. A matrix with 2 or more columns gives a warning.

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

Sidebar

Related Questions

I know that this question had already been asked a couple of times before,
I know I asked a related question earlier. I just had another thought. using
i had asked earlier about the same kind of question but that was in
I asked a question similar to this earlier, and had the original question resolved.
(I asked this question earlier, but had forgotten to mention some constraints. This is
I had asked a question about this earlier, but it didn't get answered right
I asked this question previously and thought I had it figured out but it
This is a followup question to another question I asked earlier. I thought I
I had asked a question earlier( How to keep this counter from reseting at
I had asked this question Adding more attributes to LINQ to SQL entity Now,

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.