Matrix expression causes error “requires numeric/complex matrix/vector arguments”?

后端 未结 4 1916
时光说笑
时光说笑 2020-12-03 09:54
ma=diag(3)+t(da)%*%da

R Code above, error message as follows:

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


        
4条回答
  •  渐次进展
    2020-12-03 10:41

    Matrix expression causes error “requires numeric/complex matrix/vector arguments”?

    This error occurs because you are passing a String in vector and As string cannot be multiply. matrix(c('1','2','2','1'), nrow=2,ncol=2,byrow=TRUE)->> J

    To correct it pass a numeric/complex arguments it works. matrix(c(1,2,2,1), nrow=2,ncol=2,byrow=TRUE)->> j

    then use this t = j %*% t(j) //it will print the multiplication of matrix transpose and matrix. print(t)

提交回复
热议问题