-
Notifications
You must be signed in to change notification settings - Fork 0
/
Udemy - Financial Statement Analysis.R
88 lines (70 loc) · 2.11 KB
/
Udemy - Financial Statement Analysis.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#Udemy - Financial Statement Analysis
#12/19/2021
#Data
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)
#Solution
#functions needed
?round()
mean()
max()
min()
#Calculate Profit As The Differences Between Revenue And Expenses
profit <- revenue - expenses
profit
#Calculate Tax As 30% Of Profit And Round To 2 Decimal Points
tax <- round(0.30 * profit, digits=2)
tax
#Calculate Profit Remaining After Tax Is Deducted
profit.after.tax <- profit - tax
profit.after.tax
#Calculate The Profit Margin As Profit After Tax Over Revenue
#Round To 2 Decimal Points, Then Multiply By 100 To Get %
profit.margin <- round(profit.after.tax/revenue, 2) * 100
profit.margin
#Calculate The Mean Profit After Tax For The 12 Months
mean_pat <- mean(profit.after.tax)
mean_pat
#Find The Months With Above-Mean Profit After Tax
good.months <- profit.after.tax > mean_pat
good.months
#Bad Months Are The Opposite Of Good Months !
bad.months <- profit.after.tax > good.months
bad.months
#The Best Month Is Where Profit After Tax Was Equal To The Maximum
best.month <- profit.after.tax == max(profit.after.tax)
best.month
#The Worst Month Is Where Profit After Tax Was Equal To The Minimum
worst.month <- profit.after.tax == min(profit.after.tax)
worst.month
#Convert All Calculations To Units Of One Thousand Dollars
revenue.1000 <- round(revenue / 1000)
expenses.1000 <- round(expenses/1000)
profit.1000 <- rpound(profit/1000)
profit.after.tax.1000 <- round(profit.after.tax/1000)
#Print Results
revenue.1000
expenses.1000
profit.1000
profit.after.tax.1000
profit.margin
good.months
bad.months
best.month
worst.month
#BONUS:
#Preview Of What's Coming In The Next Section
#rbind is row binding
M <- rbind(
revenue.1000,
expenses.1000,
profit.1000,
profit.after.tax.1000,
profit.margin,
good.months,
bad.months,
best.month,
worst.month
)
#Print The Matrix
M