## create a detaframe
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)
)
print(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
str(df)
## 'data.frame': 4 obs. of 8 variables:
## $ TradeID : num 701 702 703 704
## $ InvestorName: chr "Aman" "Riya" "Karan" "Neha"
## $ StockSector : Factor w/ 3 levels "Banking","IT",..: 2 1 2 3
## $ TradeType : Factor w/ 2 levels "Buy","Sell": 1 2 1 2
## $ Shares : num 10 15 20 12
## $ BuyPrice : num 1500 1200 1400 900
## $ SellPrice : num 1600 1250 1500 950
## $ Brokerage : num 50 70 60 40