Latihan - Pratikum week 4
1 Data Set
library(kableExtra)
# Membuat dataset karyawan
employees <- data.frame(
ID = c(1,2,3,4,5),
Name = c("Bagas","Joan","Alya","Dwi","Nabil"),
Age = c(25,30,27,35,40),
Salary = c(5000,7000,6500,10000,12000),
Position = c("Staff","Supervisor","Staff","Manager","Director"),
Performance = c("Good","Very Good","Average","Good","Very Good")
)
# Menampilkan dataset
kable(employees)| ID | Name | Age | Salary | Position | Performance |
|---|---|---|---|---|---|
| 1 | Bagas | 25 | 5000 | Staff | Good |
| 2 | Joan | 30 | 7000 | Supervisor | Very Good |
| 3 | Alya | 27 | 6500 | Staff | Average |
| 4 | Dwi | 35 | 10000 | Manager | Good |
| 5 | Nabil | 40 | 12000 | Director | Very Good |
2 Kolom Bonus
# Membuat kolom bonus
employees$Bonus <- 0
for(i in 1:nrow(employees)){
if(employees$Performance[i] == "Very Good"){
employees$Bonus[i] <- employees$Salary[i] * 0.20
} else if(employees$Performance[i] == "Good"){
employees$Bonus[i] <- employees$Salary[i] * 0.10
} else{
employees$Bonus[i] <- employees$Salary[i] * 0.05
}
}
# Menampilkan tabel dengan bonus
employees4 Table Sampai Manager (simulasi while loop)
manager_index <- which(employees$Position == "Manager")
until_manager <- employees[1:manager_index, c("Name","Position")]
until_manager5 Tabel Skip Performance Average
6 Grafik salery
barplot(employees$Salary,
names.arg = employees$Name,
col = c("skyblue","orange","lightgreen","purple","red"),
main = "Salary of Employees",
xlab = "Employee Name",
ylab = "Salary")7 References
Devore, J. L. (2015). Probability and Statistics for Engineering and the Sciences (9th Edition). Cengage Learning. (Emphasizes inference procedures, including t-tests, ANOVA, and nonparametric methods, with strong engineering examples.)
Hogg, R. V., McKean, J. W., & Craig, A. T. (2019). Introduction to Mathematical Statistics (8th Edition). Pearson. (Detailed coverage of statistical inference, Bayesian methods, and decision theory for technical audiences.)
Casella, G., & Berger, R. L. (2021). Statistical Inference (2nd Edition). Cengage Learning. (Advanced treatment of sufficiency, likelihood, and asymptotic inference, ideal for engineering grad students.)