Challenge: QR Matrix Factorization

Solve this challenge on QR matrix factorization in R.

We'll cover the following

Exercise

Write the R code needed to retrieve the orthogonal factor QQ of the QR factorization on the following rectangular matrix:

A=[422531]A = \begin{bmatrix} 4 & 2 \\ 2 & 5 \\ -3 & -1 \end{bmatrix}

Sample input

This is what the sample input looks like:

c(4, 2, -3, 2, 5, -1)

Expected output

The expected output looks like this:

           [,1]       [,2]
[1,] -0.7427814  0.2331018
[2,] -0.3713907 -0.9234419
[3,]  0.5570860 -0.3048255

Use the code editor below to implement your solution.

Get hands-on with 1200+ tech skills courses.