matrix by matrix in R markdown

Three minor corrections should be sufficient to make this work for both, HTML and PDF output: remove the backslash before the closing bracket in \right\) delete the empty line in the middle specify the column alignment in each array environment, e.g., with \begin{array}{cc} –

Inverse of matrix in R

solve(c) does give the correct inverse. The issue with your code is that you are using the wrong operator for matrix multiplication. You should use solve(c) %*% c to invoke matrix multiplication in R. R performs element by element multiplication when you invoke solve(c) * c.

Error in R: nonconformable arguments. Not true?

this is my code: where censored is my data table, including 200 (censored) values of y and 200 values of x. Everything works, but when running the optim command, i get the following error: I know what it means, but since x is a 200 by 2 matrix, and b[1:2] a vector of 2 by … Read more

Finding dot product in r

Without using matrices or any special libraries: The dot product of two vectors can be calulated by multiplying them element-wise with * then summing the result.

R memory management / cannot allocate vector of size n Mb

Consider whether you really need all this data explicitly, or can the matrix be sparse? There is good support in R (see Matrix package for e.g.) for sparse matrices. Keep all other processes and objects in R to a minimum when you need to make objects of this size. Use gc() to clear now unused memory, or, better only create … Read more