hospital <- data.frame(
  PatientID = c(101, 102, 103, 104, 105),
  PatientName = c("Aman", "Riya", "Karan", "Neha", "Rohit"),
  Gender = factor(c("Male", "Female", "Male", "Female", "Male")),
  Ward = factor(c("General", "ICU", "General", "Private", "ICU")),
  TreatmentCost = c(12000, 25000, 15000, 30000, NA),
  MedicineCost = c(3000, 5000, 4000, 6000, 4500),
  DaysAdmitted = c(3, 5, 2, 6, 4)
)

str(hospital)        # Structure of data frame
## 'data.frame':    5 obs. of  7 variables:
##  $ PatientID    : num  101 102 103 104 105
##  $ PatientName  : chr  "Aman" "Riya" "Karan" "Neha" ...
##  $ Gender       : Factor w/ 2 levels "Female","Male": 2 1 2 1 2
##  $ Ward         : Factor w/ 3 levels "General","ICU",..: 1 2 1 3 2
##  $ TreatmentCost: num  12000 25000 15000 30000 NA
##  $ MedicineCost : num  3000 5000 4000 6000 4500
##  $ DaysAdmitted : num  3 5 2 6 4
summary(hospital)    # Summary statistics
##    PatientID   PatientName           Gender       Ward   TreatmentCost  
##  Min.   :101   Length:5           Female:2   General:2   Min.   :12000  
##  1st Qu.:102   Class :character   Male  :3   ICU    :2   1st Qu.:14250  
##  Median :103   Mode  :character              Private:1   Median :20000  
##  Mean   :103                                             Mean   :20500  
##  3rd Qu.:104                                             3rd Qu.:26250  
##  Max.   :105                                             Max.   :30000  
##                                                          NA's   :1      
##   MedicineCost   DaysAdmitted
##  Min.   :3000   Min.   :2    
##  1st Qu.:4000   1st Qu.:3    
##  Median :4500   Median :4    
##  Mean   :4500   Mean   :4    
##  3rd Qu.:5000   3rd Qu.:5    
##  Max.   :6000   Max.   :6    
## 
dim(hospital)        # Dimensions
## [1] 5 7
nrow(hospital)       # Number of rows
## [1] 5
ncol(hospital)       # Number of columns
## [1] 7
colnames(hospital)   # Column names
## [1] "PatientID"     "PatientName"   "Gender"        "Ward"         
## [5] "TreatmentCost" "MedicineCost"  "DaysAdmitted"
retail <- data.frame(
  BillID = c(501,502,503,504,505,506),
  CustomerName = c("Aman","Riya","Karan","Neha","Rohit","Simran"),
  Gender = c("Male","Female","Male","Female","Male","Female"),
  Membership = c("Gold","Silver","Gold","None","Silver","Gold"),
  Category = c("Grocery","Electronics","Clothing","Grocery","Electronics","Clothing"),
  Quantity = c(10,1,3,8,2,5),
  CostPrice = c(50,20000,800,60,18000,700),
  SellingPrice = c(70,25000,1000,80,22000,900),
  Discount = c(100,2000,150,50,500,300),
  DeliveryType = c("Home","Store","Home","Store","Home","Home"),
  stringsAsFactors = FALSE
)

retail
##   BillID CustomerName Gender Membership    Category Quantity CostPrice
## 1    501         Aman   Male       Gold     Grocery       10        50
## 2    502         Riya Female     Silver Electronics        1     20000
## 3    503        Karan   Male       Gold    Clothing        3       800
## 4    504         Neha Female       None     Grocery        8        60
## 5    505        Rohit   Male     Silver Electronics        2     18000
## 6    506       Simran Female       Gold    Clothing        5       700
##   SellingPrice Discount DeliveryType
## 1           70      100         Home
## 2        25000     2000        Store
## 3         1000      150         Home
## 4           80       50        Store
## 5        22000      500         Home
## 6          900      300         Home
retail$GrossRevenue <- retail$Quantity * retail$SellingPrice
retail$TotalCost <- retail$Quantity * retail$CostPrice
retail$NetRevenue <- retail$GrossRevenue - retail$Discount
retail$Profit <- retail$NetRevenue - retail$TotalCost