Real time Scenario on vectors/Matrix:

Scenario: Assume that You are working as a data scientist for a consulting firm E&Y. One of your colleagues from the Auditing department has asked you to help them assess the financial statement of organization.

You have been supplied with two vectors of data: monthly revenue and monthly expenses for the financial year.

Input: Please use the below two vectors as Dataset

revenue <- c(14574.49, 7606.46, 8611.41, 9175.41, 8058.65, 8105.44, 11496.28, 9766.09, 10305.32, 14379.96, 10713.97, 15433.50)

expenses <- c (12051.82, 5695.07, 12319.20, 12089.72, 8658.57, 840.20, 3285.73, 5821.12, 6976.93, 16618.61, 10054.37, 3803.96)

 Your task is to calculate the following financial metrics:

1.profit for each month

2. profit after tax for each month (the tax rate is 30%)

3. profit margin for each month – equals to profit after tax divided by revenue

4. Good months – where the profit after tax was greater than the mean for the year

5.bad months – where the profit after tax was less than the mean for the year

6. The best month – where the profit after tax was max for the year

7.The worst month – where the profit after tax was min for the year

Prerequisites to work on this scenario:

1. All results need to be presented as vectors.

2.Results for dollar values need to be calculated with $0.01 precision (with no decimals)

3. Results for the profit margin ratio need to be presented in units of % with no decimal points.

Now its Time to think how to provide the solution to the E&Y Auditing Team?????

First Let us look at the financial Metrics step by step mentioned above and will try to apply all the Operation and Functions available to calculate the Metrics:

  1. Profit: When we have Revenue & Expenses History of an Auditing Firm, we Calculate the total Profit by performing the differences between Total revenue generated & Expenses spent.     

Profit for each month = revenue – Expenses.

2.profit after tax for each month (the tax rate is 30%) and round it to 2 decimal points.

Now we are getting profit from step 1, tax = round (0.30 * profit,2)

3. profit margin for each month = profit after tax divided by revenue.

we have already revenue as our input ,Now let’s calculate Profit after tax

Profit after Tax:  profit – tax

profit margin = profit_after_tax divided by revenue

Now Margin Profit is calculated.

4& 5 Good months and Bad Months:

Calculate the mean of the profit_after_tax.

Now mean is calculated, let us calculate the good Months and Bad Months.

6& 7: calculate Best & worst Months:

Convert all calculations to one thousand dollars and print all the results

Let’s Build the matrix and Bind all the fields as rows and Months should be displayed as columns:

Output:

Here we can see that all the financial metrics are shown in rows and Months are shown in columnar data.

Hope this scenario gives a clear Idea of using Vectors, matrix, Functions and Operations.