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 question.(5)

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

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/How to fix “requires numeric/complex matrix/vector arguments in r”?
Next
Answered
Tiago Dufour
  • 7
Tiago Dufour
Asked: May 17, 20222022-05-17T13:01:31+00:00 2022-05-17T13:01:31+00:00In: r

How to fix “requires numeric/complex matrix/vector arguments in r”?

  • 7

. Advertisement .

..3..

. Advertisement .

..4..

I get the “requires numeric/complex matrix/ vector arguments in R” error as the title says. How can I fix it so the error goes away? Here is my detail:

ma=diag(3)+t(da)%*%da
V45 V46 V47 V48 V49 V50 V51 
 1 0.461727059 2.357732985 -1.536932071 -1.34425710 0.893541975 -0.0676913075 -0.86532231
 2 0.253022555 1.524473647 -0.588911138 -1.65207275 -0.072255170 -0.5212951533 -1.43686625
 3 0.824678362 1.497001189 0.335973892 -0.84027799 0.275289411 -0.2921928001 -0.16277595
 4 0.854530787 2.258305198 0.107346531 -1.69194014 -0.841572928 -1.1153931009 -1.939461341
 5 1.148286984 -0.232390389 -0.498465734 -0.45728816 0.352889082 0.9868844505 -0.68401129

When I operated it, I received the error text:

Error in t(da) %*% da : requires numeric/complex matrix/vector arguments

I appreciate any help from you.

matrix
  • 2 2 Answers
  • 339 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    dttutoria Expert
    2022-06-06T08:22:05+00:00Added an answer on June 6, 2022 at 8:22 am

    The cause: Because a large number of device learning libraries use matrix multiplication, you can see a similar error if one or more of your inputs are of the class character while the algorithm expects numeric.

    Another reason: If you try to pass a data frame where a matrix needs to be.

    Solution: 

    You must convert the data.frame to a matrix in order for the matrix multiplication to work:

    t(da)%*%as.matrix(da)

    It produces a 7×7 matrix, which you can’t add to the 3×3 identity matrix you’re working with. The code shows something like:

    ma=diag(7)+t(da)%*%as.matrix(da)

     

    • 18
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Nathan Besnard
    2022-05-25T19:58:49+00:00Added an answer on May 25, 2022 at 7:58 pm

    This error can also be triggered if you try to pass a dataframe where a matrix should be.

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

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

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.