linearCombination | R Documentation |
Calculate the linear combination of a matrix
linearCombination(x, coeffs, version = 1)
x |
numeric matrix |
coeffs |
numeric vector of coefficients |
version |
1 or 2 (default: 1). Allows for two different versions of calculation both of which should return the same! |
(x <- randomMatrix(c(4, 2)))
(coeffs <- rnorm(ncol(x)))
# Calculate the linear combination manually
LC1 <- x[, 1] * coeffs[1] + x[, 2] * coeffs[2]
# Caluclate with linearCombination()
LC2 <- linearCombination(x, coeffs)
# The result shoulc be the same!
all.equal(LC1, LC2) # TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.