Latihan - Pratikum week 4

Logo

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
employees

3 Tabel Salary

salary_above_6000 <- employees[employees$Salary > 6000, ]

salary_above_6000

4 Table Sampai Manager (simulasi while loop)

manager_index <- which(employees$Position == "Manager")

until_manager <- employees[1:manager_index, c("Name","Position")]

until_manager

5 Tabel Skip Performance Average

no_average <- employees[employees$Performance != "Average",
                        c("Name","Performance")]

no_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")

6.1 Grafik performance

performance_table <- table(employees$Performance)

barplot(performance_table,
        col = c("gold","lightblue","lightgreen"),
        main = "Employee Performance",
        xlab = "Performance Level",
        ylab = "Number of Employees")

7 References

  1. 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.)

  2. 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.)

  3. 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.)