- Using data set tips, we will first manipulate the columns total_bill and tip to calculate the tip percentage for each observation, denoted as tip_percentage:
data(tips)
tips = subset(tips, select = -c(sex, smoker, day, time, size))
tips$tip_percentage <- round((tips$tip / tips$total_bill) * 100, 2)
summary(tips)
## total_bill tip tip_percentage
## Min. : 3.07 Min. : 1.000 Min. : 3.56
## 1st Qu.:13.35 1st Qu.: 2.000 1st Qu.:12.91
## Median :17.80 Median : 2.900 Median :15.47
## Mean :19.79 Mean : 2.998 Mean :16.08
## 3rd Qu.:24.13 3rd Qu.: 3.562 3rd Qu.:19.15
## Max. :50.81 Max. :10.000 Max. :71.03
- In this instance, we will build random samples of the tip percentages with the formula: \(\overline{x} = (x_1+x_2+x_3+...+x_{12})/12\)