Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Sales and Revenue | Matrices
R Introduction

bookChallenge: Sales and Revenue

Note
Note

If you want to multiply rows (or columns) by different values, the length of the vector you use must match the number of rows (or columns) in the matrix. This ensures that each row (or column) element is multiplied by the corresponding value.

Task

Swipe to start coding

You have the selling data for a local furniture store stored in the sellings matrix:

MonthSofaArmchairDining tableDining chairBookshelf
March1621302310
April4039132116
May1121363216

And a vector of prices named prices:

SofaArmchairDining tableDining chairBookshelf
34015011545160

Your tasks are:

  1. Output the total number of items sold each month.
  2. Transpose the sellings matrix and reassign the result to the sellings variable.
  3. Find out the revenue for each good by multiplying sellings and prices. Save the result in the income variable.
  4. Output the monthly revenues.
  5. Output the total three months' revenue.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 7
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

Awesome!

Completion rate improved to 2.27

bookChallenge: Sales and Revenue

Swipe to show menu

Note
Note

If you want to multiply rows (or columns) by different values, the length of the vector you use must match the number of rows (or columns) in the matrix. This ensures that each row (or column) element is multiplied by the corresponding value.

Task

Swipe to start coding

You have the selling data for a local furniture store stored in the sellings matrix:

MonthSofaArmchairDining tableDining chairBookshelf
March1621302310
April4039132116
May1121363216

And a vector of prices named prices:

SofaArmchairDining tableDining chairBookshelf
34015011545160

Your tasks are:

  1. Output the total number of items sold each month.
  2. Transpose the sellings matrix and reassign the result to the sellings variable.
  3. Find out the revenue for each good by multiplying sellings and prices. Save the result in the income variable.
  4. Output the monthly revenues.
  5. Output the total three months' revenue.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 7
single

single

some-alt