Moore-Penrose generalized determinant Is there a function in R to calculate the generalized determinant of a singular matrix? (similar to the ginv() used to compute the generalized inverse)
 A: That determinant would be the product of all singular values that you consider to be nonzero, leading to this solution:
# The generalized determinant of x
det.mp <- function(x) {
     sigma <- zapsmall(svd(x)$d)   # The singular values of x
     prod(sigma[sigma != 0])       # Product of the nonzero singular values
}

Here is an application:
# Create test data
p <- 15                            # Number of columns
n <- 6                             # Number of rows
set.seed(17)
x <- matrix(rnorm(n * p), n, p)
x <- rbind(x, x[1,])               # Assure at least one singularity
det.mp(x)

The output is 3013.513.  Note that x does not have to be a square matrix.
In larger problems, to avoid overflow you might need instead to obtain the logarithm of the determinant:
sum(log(sigma[sigma != 0]))

(This assumes all singular values are non-negative, because when log is applied to negative values it just returns NaN.  Negative values can be handled by the related but slightly more complicated solution
tau <-sigma[sigma != 0]
list(modulus=sum(log(abs(tau))), sign=prod(sign(tau)))

which returns the logarithm of the magnitude of the determinant along with the sign of the determinant, exactly as in the built-in function determinant with the "logarithm" option.)
