##Create a new column called "employment_length_days".
#Fill this new column (“employment_length_days”) using a for loop and if statement with the following conditions:
#For those STILL employed (DO NOT have a "termination_date"), find the difference between August 11, 2021 and their "hire_date".
#For those NO LONGER employed (DO have a "termination_date"), find the difference between their "termination_date" and their "hire_date".
#1: Prior to your loop, set the current date using the following: today <- as.Date("2021-08-11")
#2: Then, you could use the "difftime" function to calculate the correct number of days. As an example: difftime(x,y)
我目前的进度
for (i in 1:nrow(Employees)) {
if (Employees$termination_date = "NULL") {
difftime(2021-08-11, Employees$hire_date) <- Employees$employment_length_days
} else if (Employees$termination_date = "") {
difftime(Employees$termination_date, Employees$hire_date) <- Employees$employment_length_days
}
}