[cite_start]This section prepares the environment by loading libraries and the dataset.
# [cite_start]Load the dataset provided in the file
df <- data.frame(
TradeID = c(701,702,703,704),
InvestorName = c("Aman","Riya","Karan","Neha"),
StockSector = factor(c("IT","Banking","IT","Pharma")),
TradeType = factor(c("Buy","Sell","Buy","Sell")),
Shares = c(10,15,20,12),
BuyPrice = c(1500,1200,1400,900),
SellPrice = c(1600,1250,1500,950),
Brokerage = c(50,70,60,40)
)
df## TradeID InvestorName StockSector TradeType Shares BuyPrice SellPrice
## 1 701 Aman IT Buy 10 1500 1600
## 2 702 Riya Banking Sell 15 1200 1250
## 3 703 Karan IT Buy 20 1400 1500
## 4 704 Neha Pharma Sell 12 900 950
## Brokerage
## 1 50
## 2 70
## 3 60
## 4 40