#R codes ##Data Loading
library(readxl)
## Warning: package 'readxl' was built under R version 4.4.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
library(gridExtra)
## Warning: package 'gridExtra' was built under R version 4.4.3
Tvs_bs <- read_excel("E:/R studio/tvsbs.xlsx")
Tvs_bs<-as.data.frame(Tvs_bs)
colnames(Tvs_bs) <- make.names(colnames(Tvs_bs))
colnames(Tvs_bs) <- trimws(colnames(Tvs_bs))
Tvs_bs_long <- reshape(Tvs_bs,
varying = c("X2024", "X2023", "X2022", "X2021", "X2020"),
v.names = "Amount",
timevar = "Year",
times = c("2024","2023","2022","2021", "2020"),
direction = "long")
rownames(Tvs_bs_long) <- NULL
#codes by SHRAVAN SHANKAR.J
#Total Reserves and Surplus plot
b1_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items=="TotalReservesandSurplus",])
p1_Tvs=ggplot(b1_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in Crores",
title="Total Reserves and Surplus",
caption = "B/S DATA",
subtitle="TVS Motors (2020 - 2024)")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(3000, 8000), # Set y-axis limits
breaks = seq(3000, 8000, by = 1000), # Set the breaks on the y-axis
labels = seq(30, 80, by = 10)) # Label the y-axis with values from 30 to 80
grid.arrange(p1_Tvs)
#codes by SHRAVAN SHANKAR.J
#Total Current Liabilities plot
b2_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items == "TotalCurrentLiabilities",])
p2_Tvs=ggplot(b2_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in Crores",
title="Total Current Liabilities",
caption = "B/S DATA",
subtitle="TVS Motors (2020 - 2024)")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(4000, 8000), # Set y-axis limits
breaks = seq(4000, 8000, by = 1000), # Set the breaks on the y-axis
labels = seq(40, 80, by = 10)) # Label the y-axis with values from 40 to 80
grid.arrange(p2_Tvs)
#codes by SHRAVAN SHANKAR.J
#Total Current Assets plot
b3_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items == "TotalCurrentAssets",])
p3_Tvs=ggplot(b3_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=3)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in Crores",
title="Total Current Assets",
subtitle="TVS Motors(2020 - 2024)",
caption = "B/S DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(3000, 5000), # Set y-axis limits
breaks = seq(3000, 5000, by = 500), # Set the breaks on the y-axis
labels = seq(30, 50, by = 5))
grid.arrange(p3_Tvs)
#codes by SHRAVAN SHANKAR.J
#Cash And Cash Equivalents plot
b4_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items == "CashAndCashEquivalents",])
p4_Tvs=ggplot(b4_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in Crores",
title="Cash And CashEquivalents",
subtitle="TVS Motors (2020 - 2024)",
caption = "B/S DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(200, 1000), # Set y-axis limits
breaks = seq(200, 1000, by = 200), # Set the breaks on the y-axis
labels = seq(2, 10, by = 2))
grid.arrange(p4_Tvs)
#codes by SHRAVAN SHANKAR.J
#Trade Receivables plot
b5_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items == "TradeReceivables",])
p5_Tvs=ggplot(b5_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in crores",
title="Trade Receivables",
subtitle="TVS Motors (2020 - 2024)",
caption = "B/S DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(500, 1500), # Set y-axis limits
breaks = seq(500, 1500, by = 500), # Set the breaks on the y-axis
labels = seq(5, 15, by = 5))
grid.arrange(p5_Tvs)
#codes by SHRAVAN SHANKAR.J
#Trade Payables plot
b6_tvs=as.data.frame(Tvs_bs_long[Tvs_bs_long$Items == "TradePayables",])
p6_Tvs=ggplot(b6_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in Crores",
title="Trade Payables",
subtitle="TVS Motors (2020 - 2024)",
caption = "B/S DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
scale_y_continuous(
limits = c(2500, 5500), # Set y-axis limits
breaks = seq(2500, 5500, by = 500), # Set the breaks on the y-axis
labels = seq(25, 55, by = 5))
grid.arrange(p6_Tvs)
#codes by GANESH
#Profit or Loss for the Period plot
tvs_pl=read_excel("E:/R studio/tvspl.xlsx")
tvs_pl<-as.data.frame(tvs_pl)
# Clean column names (if needed)
colnames(tvs_pl) <- make.names(colnames(tvs_pl))
colnames(tvs_pl) <- trimws(colnames(tvs_pl))
#-----------------------------------
tvspllong <- reshape(tvs_pl,
varying = c("X2024", "X2023", "X2022", "X2021", "X2020"),
v.names = "Amount",
timevar = "Year",
times = c("2024","2023","2022","2021", "2020"),
direction = "long")
b1_tvs=as.data.frame(tvspllong[tvspllong$Items=="Profit_orLossForThePeriod",])
p1_tvspl=ggplot(b1_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="Profit or loss for the period",
caption = "P&L DATA",
subtitle="TVS (2020 - 2024)")+
scale_y_continuous(
limits = c(500, 2500),
breaks = seq(500, 2500, by = 500),
labels = seq(50, 250, by = 50))
print(p1_tvspl)
#codes by GANESH
#Revenue from operations (Gross) plot
b2_tvs=as.data.frame(tvspllong[tvspllong$Items == "RevenueFromOperations_Gross",])
p2_tvspl=ggplot(b2_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="Revenue from operations (Gross)",
caption = "P&L DATA",
subtitle="TVS (2020 - 2024)")+
scale_y_continuous(
limits = c(15000, 35000), # Set y-axis limits
breaks = seq(15000, 35000, by = 5000), # Set the breaks on the y-axis
labels = seq(15, 35, by = 5)) # Label the y-axis with values from 50 to 80
print (p2_tvspl)
#codes by GANESH
# EBT plot
b3_tvs=as.data.frame(tvspllong[tvspllong$Items == "Profit_orLossBeforeTax",])
p3_tvspl=ggplot(b3_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="EBT (Earnings Before Tax)",
subtitle="TVS (2020 - 2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(750, 3100), # Set y-axis limits
breaks = seq(700, 3100, by = 300 ), # Set the breaks on the y-axis
labels = seq(70, 310, by = 30 ))
print(p1_tvspl)
#codes by GANESH
#Total Revenue plot
b4_tvs=as.data.frame(tvspllong[tvspllong$Items == "TotalRevenue",])
p4_tvspl=ggplot(b4_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="TotalRevenue",
subtitle="TVS (2020 - 2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(15000, 35000), # Set y-axis limits
breaks = seq(15000, 35000, by = 5000 ), # Set the breaks on the y-axis
labels = seq(150, 350, by = 50 ))
print(p4_tvspl)
#codes by GANESH
# Other Income plot
b5_tvs=as.data.frame(tvspllong[tvspllong$Items == "OtherIncome",])
p5_tvspl=ggplot(b5_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=2),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="Other Income",
subtitle="TVS (2020 - 2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(15, 150), # Set y-axis limits
breaks = seq(15, 150, by = 15 ), # Set the breaks on the y-axis
labels = seq(15, 150, by = 15 ))
print(p5_tvspl)
#codes by GANESH
#Other operating revenues
b6_tvs=as.data.frame(tvspllong[tvspllong$Items == "OtherOperatingRevenues",])
p6_tvspl=ggplot(b6_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=2),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="Other operating Revenues",
subtitle="TVS (2020 - 2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(100, 400), # Set y-axis limits
breaks = seq(100, 400, by = 100 ), # Set the breaks on the y-axis
labels = seq(100, 400, by = 100 ))
print(p6_tvspl)
#codes by GANESH
#Total expenses
b7_tvs=as.data.frame(tvspllong[tvspllong$Items == "TotalExpenses",])
p7_tvspl=ggplot(b7_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col= "green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title= "Total Expenses",
subtitle = "TVS (2020-2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(15000,30000),
breaks = seq(15000,30000, by= 5000),
labels = seq(15000,30000, by = 5000))
print(p7_tvspl)
#codes by GANESH
#Finance Costs
b8_tvs=as.data.frame(tvspllong[tvspllong$Items == "FinanceCosts",])
p8_tvspl=ggplot(b8_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col= "green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title= "finance costs",
subtitle = "TVS (2020-2024)",
caption = "P&L DATA")+
scale_y_continuous(
limits = c(100,190),
breaks = seq(100,190, by= 10),
labels = seq(100,190, by = 10))
print(p8_tvspl)
# codes by GIRISH.M
#Net Profit Before Tax PLOT
tvs_cf=read_excel("E:/R studio/tvscf.xlsx")
tvs_cf<-as.data.frame(tvs_cf)
colnames(tvs_cf) <- make.names(colnames(tvs_cf))
colnames(tvs_cf) <- trimws(colnames(tvs_cf))
tvs_cf_long <- reshape(tvs_cf,
varying = c("X2020","X2021","X2022","X2023","X2024"),
v.names = "Amount",
timevar = "Year",
times = c("2020","2021","2022","2023", "2024"),
direction = "long")
rownames(tvs_cf_long) <- NULL
b1_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items=="NetProfitBeforeTax",])
p1_tvscf=ggplot(b1_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in crores",
title="Net Profit Before Tax",
caption = "C/F DATA",
subtitle="TVS Motors (2020 - 2024)")+
scale_y_continuous(
limits = c(500, 3000), # Set y-axis limits
breaks = seq(500, 3000, by = 500), # Set the breaks on the y-axis
labels = seq(500, 3000, by = 500)) # Label the y-axis with values
print(p1_tvscf)
#codes by GIRISH.M
#Net Cash From Operating Activities PLOT
b2_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "NetCashFromOperatingActivities",])
p2_tvscf=ggplot(b2_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in Crores",
title="Net Cash From Operating Activities",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
scale_y_continuous(
limits = c(1000, 4000), # Set y-axis limits
breaks = seq(1000, 4000, by = 500), # Set the breaks on the y-axis
labels = seq(10, 40, by = 5))
print(p2_tvscf)
#Codes by GIRISH.M
#Net Dec on In Cash and Cash Equivalents
b3_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "NetDecreaseOrIncreaseInCashandCashEquivalents",])
p3_tvscf=ggplot(b3_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount crores",
title="Net Dec Or Inc in Cash and Cash Equivalents",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
scale_y_continuous(
limits = c(-600, 500), # Set y-axis limits
breaks = seq(-600, 500, by = 100), # Set the breaks on the y-axis
labels = seq(-60, 50, by = 10))
print(p3_tvscf)
#codes by GIRISH.M
#Opening Cash & Cash Equivalents
b4_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "OpeningCash&CashEquivalents",])
p4_tvscf=ggplot(b4_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
labs(x="Year",y="Amount in crores",
title="Opening Cash & Cash Equivalents",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
scale_y_continuous(
limits = c(30, 900), # Set y-axis limits
breaks = seq(30, 900, by = 30), # Set the breaks on the y-axis
labels = seq(3, 90, by = 3))
print(p4_tvscf)
#codes by GIRISH.M
#Closing Cash & Cash Equivalents Plot
b5_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "ClosingCash&CashEquivalents",])
p5_tvscf=ggplot(b5_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in crores",
title="Closing Cash & Cash Equivalents",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
scale_y_continuous(
limits = c(200, 900), # Set y-axis limits
breaks = seq(200, 900, by = 50), # Set the breaks on the y-axis
labels = seq(20, 90, by = 5))
print(p5_tvscf)
#codes by GIRISH.M
#Net Cash used from Financing Activities plot
b6_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "NetCashusedin_orfromFinancingActivities",])
p6_tvscf=ggplot(b6_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in crores",
title="Net Cash used in or from Financing Activities",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
scale_y_continuous(
limits = c(-2000, 1000), # Set y-axis limits
breaks = seq(-2000, 1000, by = 1000), # Set the breaks on the y-axis
labels = seq(-2000, 1000, by = 1000))
print(p6_tvscf)
#codes by GIRISH.M
#Net Cash used in or from Plot
b7_tvs=as.data.frame(tvs_cf_long[tvs_cf_long$Items == "NetCashusedin_orfrom",])
p7_tvscf=ggplot(b7_tvs,aes(x=Year,y=Amount))+
geom_point(col="blue",size=4)+
geom_line(aes(x=Year,Amount, group=1),
col="green",
linewidth=2)+
labs(x="Year",y="Amount in crores",
title="Net Cash used in or from",
subtitle="TVS Motors (2020 - 2024)",
caption = "C/F DATA")+
geom_text(aes(label = Amount), vjust = -1, color = "black") + # Display numbers above points
theme_minimal() +
scale_y_continuous(
limits = c(-2500, -500), # Set y-axis limits
breaks = seq(-2500, -500, by = 500), # Set the breaks on the y-axis
labels = seq(-2500, -500, by = 500))
print(p7_tvscf)
# codes by GANESH
# Define groups from the items
tvs_cms_grp <- "CostOfMaterialsConsumed"
tvs_rev_grp <- "TotalRevenue"
# Calculate Gross Profit (Revenue - COGS) for each year
tvs_gpr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_cms_grp],
tvspllong$Year[tvspllong$Item %in% tvs_cms_grp], sum)
tvs_revr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_rev_grp],
tvspllong$Year[tvspllong$Item %in% tvs_rev_grp], sum)
# Compute Gross Profit Ratio
tvs_gp_ratio <- ((tvs_revr_grp - tvs_gpr_grp) / tvs_revr_grp) * 100
# Create a dataframe with Year and GP Ratio
gpdf=data.frame(
Year = names(tvs_revr_grp),
TVS_GP_Ratio = unname(tvs_gp_ratio))
#net profit ratio
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_rev_grp <- "TotalRevenue"
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp], tvspllong$Year[tvspllong$Item %in% tvs_np_grp ], sum)
tvs_revr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_rev_grp], tvspllong$Year[tvspllong$Item %in% tvs_rev_grp], sum)
tvs_np_ratio <- (tvs_npr_grp/tvs_revr_grp)*100
#creating dataframe
npdf=data.frame(Year=names(tvs_revr_grp),
TVS_NP_Ratio=unname(tvs_np_ratio))
#ROA
# Define groups from the items for ROA
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_ta_grp= "TotalAssets"
#Finding the sum of items in each group year wise
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp], tvspllong$Year[tvspllong$Item %in% tvs_np_grp ], sum)
tvs_tar_grp = tapply(Tvs_bs_long$Amount[Tvs_bs_long$Item %in% tvs_ta_grp], Tvs_bs_long$Year[Tvs_bs_long$Item %in% tvs_ta_grp], sum)
#Finding the ratio of sum in each group - yearwise
tvs_roa_ratio <- (tvs_npr_grp/tvs_tar_grp)*100
#creating dataframe
roa_df=data.frame(Year=names(tvs_revr_grp),
TVS_ROA_Ratio=unname(tvs_roa_ratio))
#ROE
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_esc_grp="TotalShareholdersFunds"
#Finding the sum of items in each group year wise
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp], tvspllong$Year[tvspllong$Item %in% tvs_np_grp ], sum)
tvs_escr_grp = tapply(Tvs_bs_long$Amount[Tvs_bs_long$Item %in% tvs_esc_grp], Tvs_bs_long$Year[Tvs_bs_long$Item %in% tvs_esc_grp], sum)
#Finding the ratio of sum in each group - yearwise
tvs_roe_ratio <- (tvs_npr_grp/tvs_escr_grp)*100
#creating dataframe
roe_df=data.frame(Year=names(tvs_revr_grp),
TVS_ROE_Ratio=unname(tvs_roe_ratio))
#--------------------------------------------------------------------------------------------------------------------------
#bajaj and tvs
#Gross profit ratio
tvs_cms_grp <- "CostOfMaterialsConsumed"
tvs_rev_grp <- "TotalRevenue"
bajaj_cms_grp <- "CostOfMaterials_Consumed"
bajaj_rev_grp <- "Total_Revenue"
tvs_gpr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_cms_grp],
tvspllong$Year[tvspllong$Item %in% tvs_cms_grp], sum)
tvs_revr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_rev_grp],
tvspllong$Year[tvspllong$Item %in% tvs_rev_grp], sum)
bajaj_gpr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_cms_grp],
bajajpllong$Year[bajajpllong$Items %in% bajaj_cms_grp], sum)
bajaj_revr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_rev_grp],
bajajpllong$Year[bajajpllong$Items %in% bajaj_rev_grp], sum)
tvs_gp_ratio <- ((tvs_revr_grp - tvs_gpr_grp) / tvs_revr_grp) * 100
bajaj_gp_ratio <- ((bajaj_revr_grp - bajaj_gpr_grp) / bajaj_revr_grp) * 100
#creating dataframe
gpsdf=data.frame(
Year = names(tvs_revr_grp),
TVS_GP_Ratio = unname(tvs_gp_ratio),
BAJAJ_GP_Ratio = unname(bajaj_gp_ratio))
#Net profit
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_rev_grp <- "TotalRevenue"
bajaj_np_grp <- "ProfitLossForThePeriod_"
bajaj_rev_grp <- "Total_Revenue"
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp],
tvspllong$Year[tvspllong$Item %in% tvs_np_grp], sum)
tvs_revr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_rev_grp],
tvspllong$Year[tvspllong$Item %in% tvs_rev_grp], sum)
bajaj_npr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_np_grp],
bajajpllong$Year[bajajpllong$Items %in% bajaj_np_grp], sum)
bajaj_revr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_rev_grp],
bajajpllong$Year[bajajpllong$Items %in% bajaj_rev_grp], sum)
tvs_np_ratio <- (tvs_npr_grp / tvs_revr_grp) * 100
bajaj_np_ratio <- (bajaj_npr_grp / bajaj_revr_grp) * 100
#creating dataframe
npsdf=data.frame(
Year = names(tvs_revr_grp),
TVS_NP_Ratio = unname(tvs_np_ratio),
BAJAJ_NP_Ratio = unname(bajaj_np_ratio))
#ROA
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_ta_grp= "TotalAssets"
bajaj_np_grp = "ProfitLossForThePeriod_"
bajaj_ta_grp = "TotalAssets"
#Finding the sum of items in each group year wise
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp], tvspllong$Year[tvspllong$Item %in% tvs_np_grp ], sum)
tvs_tar_grp = tapply(Tvs_bs_long$Amount[Tvs_bs_long$Item %in% tvs_ta_grp], Tvs_bs_long$Year[Tvs_bs_long$Item %in% tvs_ta_grp], sum)
bajaj_npr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_np_grp], bajajpllong$Year[bajajpllong$Items %in% bajaj_np_grp ], sum)
bajaj_tar_grp = tapply(bajajbslong$Amount[bajajbslong$Items %in% bajaj_ta_grp], bajajbslong$Year[bajajbslong$Items %in% bajaj_ta_grp], sum)
#Finding the ratio of sum in each group - yearwise
tvs_roa_ratio <- (tvs_npr_grp/tvs_tar_grp)*100
bajaj_roa_ratio <- (bajaj_npr_grp/bajaj_tar_grp)*100
#creating dataframe
roasdf=data.frame(Year=names(tvs_revr_grp),
TVS_ROA_Ratio=unname(tvs_roa_ratio),
BAJAJ_ROA_Ratio=unname(bajaj_roa_ratio))
#ROE
tvs_np_grp <- "Profit_orLossForThePeriod"
tvs_esc_grp="TotalShareholdersFunds"
bajaj_np_grp = "ProfitLossForThePeriod_"
bajaj_esc_grp = "TotalShareholders_Funds"
#Finding the sum of items in each group year wise
tvs_npr_grp = tapply(tvspllong$Amount[tvspllong$Item %in% tvs_np_grp], tvspllong$Year[tvspllong$Item %in% tvs_np_grp ], sum)
tvs_escr_grp = tapply(Tvs_bs_long$Amount[Tvs_bs_long$Item %in% tvs_esc_grp], Tvs_bs_long$Year[Tvs_bs_long$Item %in% tvs_esc_grp], sum)
bajaj_npr_grp = tapply(bajajpllong$Amount[bajajpllong$Items %in% bajaj_np_grp], bajajpllong$Year[bajajpllong$Item %in% bajaj_np_grp ], sum)
bajaj_escr_grp = tapply(bajajbslong$Amount[bajajbslong$Item %in% bajaj_esc_grp], bajajbslong$Year[bajajbslong$Item %in% bajaj_esc_grp], sum)
#Finding the ratio of sum in each group - yearwise
tvs_roe_ratio <- (tvs_npr_grp/tvs_escr_grp)*100
bajaj_roe_ratio <- (bajaj_npr_grp/bajaj_escr_grp)*100
#creating dataframe
roesdf=data.frame(Year=names(tvs_revr_grp),
ROE_TVS_Ratio=unname(tvs_roe_ratio),
ROE_BAJAJ_Ratio=unname(tvs_roe_ratio))
print(roesdf)
## Year ROE_TVS_Ratio ROE_BAJAJ_Ratio
## 1 2020 16.36913 16.36913
## 2 2021 14.67388 14.67388
## 3 2022 18.53075 18.53075
## 4 2023 24.65389 24.65389
## 5 2024 26.94333 26.94333
print(roasdf)
## Year TVS_ROA_Ratio BAJAJ_ROA_Ratio
## 1 2020 6.331976 20.58660
## 2 2021 6.001893 14.44517
## 3 2022 7.542035 15.72232
## 4 2023 10.656007 18.07908
## 5 2024 12.968303 21.83547
print(npsdf)
## Year TVS_NP_Ratio BAJAJ_NP_Ratio
## 1 2020 3.599114 16.11256
## 2 2021 3.646675 15.69599
## 3 2022 4.294000 14.60930
## 4 2023 5.631063 14.96343
## 5 2024 6.524688 16.22731
print(gpsdf)
## Year TVS_GP_Ratio BAJAJ_GP_Ratio
## 1 2020 27.95817 38.44152
## 2 2021 25.48108 36.90682
## 3 2022 25.29061 35.46629
## 4 2023 25.94183 36.16156
## 5 2024 27.19113 36.49368
GP_IND_AVG= c("33.1045","30.8926","30.4240","30.7397","33.0330")
gpdf=data.frame(
Year = names(tvs_revr_grp),
TVS_GP_Ratio = unname(tvs_gp_ratio),
GP_IND_AVG = unname(GP_IND_AVG))
print(gpdf)
## Year TVS_GP_Ratio GP_IND_AVG
## 1 2020 27.95817 33.1045
## 2 2021 25.48108 30.8926
## 3 2022 25.29061 30.4240
## 4 2023 25.94183 30.7397
## 5 2024 27.19113 33.0330
NP_IND_AVG= c("10.6600","9.5962","9.0671", "9.6875", "11.0330")
npdf=data.frame(Year=names(tvs_revr_grp),
TVS_NP_Ratio=unname(tvs_np_ratio),
NP_IND_AVG = unname(NP_IND_AVG))
print(npdf)
## Year TVS_NP_Ratio NP_IND_AVG
## 1 2020 3.599114 10.6600
## 2 2021 3.646675 9.5962
## 3 2022 4.294000 9.0671
## 4 2023 5.631063 9.6875
## 5 2024 6.524688 11.0330
ROA_IND_AVG= c("15.4322","11.2742", "11.5511", "13.7488","16.7736")
roa_df=data.frame(Year=names(tvs_revr_grp),
TVS_ROA_Ratio=unname(tvs_roa_ratio),
ROA_IND_AVG=unname(ROA_IND_AVG))
print(roa_df)
## Year TVS_ROA_Ratio ROA_IND_AVG
## 1 2020 6.331976 15.4322
## 2 2021 6.001893 11.2742
## 3 2022 7.542035 11.5511
## 4 2023 10.656007 13.7488
## 5 2024 12.968303 16.7736
ROE_IND_AVG=c("22.5552","17.4164", "17.6729", "21.4035", "26.3625")
roe_df=data.frame(Year=names(tvs_revr_grp),
TVS_ROE_Ratio=unname(tvs_roe_ratio),
ROE_IND_AVG=unname(ROE_IND_AVG))
print(roe_df)
## Year TVS_ROE_Ratio ROE_IND_AVG
## 1 2020 16.36913 22.5552
## 2 2021 14.67388 17.4164
## 3 2022 18.53075 17.6729
## 4 2023 24.65389 21.4035
## 5 2024 26.94333 26.3625