Calculating the determinant of a matrix in r studio without the use of built-in functions

I have to get the determinant of a square matrix of any size without the use of built-in functions. Or with built-in functions that come with the base version of r.

I am now calculating the co-factor of the matrix, but then I realized that it would be very inefficient when the matrix is bigger than a 3×3. Because then I’ll have to get the cofactor of the cofactor and so on as the matrix gets bigger.

Is there a more efficient way of getting the cofactor of the first row of a matrix that is bigger than 3×3. Without the use of built-in functions, or with the use of only the built-in functions of the base r version?

Thank you in advance.

Read more here: Source link