0

I have two matrices. The first one has dimensions of 4x4 and the second one has dimensions of 4X1. In theory multiplying these two would give me a 4X1 matrix. When I tried this I got an error: requires numeric/complex matrix/vector arguments

Here is my code and proof that the dimensions are as I said:

singles=as.matrix(singles)
odds=as.matrix(odds)
singles_returns=singles%*%odds

> dim(singles)
[1] 4 4
> dim(odds)
[1] 4 1

> singles%*%odds
Error in singles %*% odds : 
  requires numeric/complex matrix/vector arguments

Any help would be appreciated

melo777
  • 27
  • 6
  • 1
    It seems as though one or more of your matrices is not numeric. Do `is.numeric(singles)` and `is.numeric(odds)` both return `TRUE`? – alan ocallaghan Oct 23 '19 at 13:31
  • Yes @aocall, you are right. odds isn't numeical. I basically have decimals. So does this mean I can't make matrix calculations when I have decimals? – melo777 Oct 23 '19 at 13:34
  • Numeric matrices in R allow for decimals, of course. Try `odds[] <- as.numeric(odds)` then `singles %*% odds` – alan ocallaghan Oct 23 '19 at 14:03
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Oct 23 '19 at 15:29

0 Answers0