How to Apply the det & determinant Functions in R (2 Examples)

This article illustrates how to compute the determinant of a matrix object using the det and determinant functions in the R programming language.

Example Data

x <- matrix(4:1, nrow = 2)        # Construct matrix in R
x
#      [,1] [,2]
# [1,]    4    2
# [2,]    3    1

Example 1: Get Determinant of Matrix

det(x)                            # Using det() function
# [1] -2

Example 2: Get Modulus of Determinant on Logarithm Scale

determinant(x)                    # Using determinant() function
# $modulus
# [1] 0.6931472
# attr(,"logarithm")
# [1] TRUE
# 
# $sign
# [1] -1
# 
# attr(,"class")
# [1] "det"

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top