Challenge: Matrix Addition

Solve this challenge on matrix addition in R.

We'll cover the following

Exercise

Write the R code required to add the following matrices:

[5728]+[1321] \begin{bmatrix} 5 & 7 \\ 2 & 8 \end{bmatrix} + \begin{bmatrix} 1 & 3 \\ 2 & 1 \end{bmatrix}

Sample input

This is what the sample input looks like:

c(5, 7, 2, 8), c(1, 3, 2, 1)

Expected output

The expected output looks like this:

c(6, 10, 4, 9)

Use the code editor below to implement your solution.

Get hands-on with 1200+ tech skills courses.