[英]How can I filter rows out if their start date is within 90 days from today and place them out until the 1st of the following month in R?
I am having difficulty finding the words to describe what I am searching for but will try.我很难找到描述我正在寻找的东西的词,但会尝试。 I would like to solve the following using R or Python (but preferably R).我想使用 R 或 Python(但最好是 R)解决以下问题。
I have a dataframe of employees with their employee ID, department, start date etc. I am looking to perform calculations for each employee but would like to ignore employees that have a start date within 90 days from today.我有一个包含员工 ID、部门、开始日期等的员工数据框。我希望为每个员工执行计算,但想忽略从今天起 90 天内开始日期的员工。 Additionally I would like for this employee to be left out of consideration until the 1st of the following month.此外,我希望在下个月 1 日之前不要考虑该员工。 So basically exclude employees until the 1st of the month following their 90th day after hire .所以基本上排除员工,直到他们雇用后第 90 天后的第 1 个月。 I do not need to include only workdays for this project.我不需要只包括这个项目的工作日。
In the below example for a report ran on May 3, 2022 I would exclude ID (22222, 33333, 44444, 666666 88888, and 99999).在以下 2022 年 5 月 3 日运行的报告示例中,我将排除 ID(22222、33333、44444、666666 88888 和 99999)。
ID | Dept | Start Date |
11111 | Sales | 04/10/2015 |
22222 | Field Tech | 04/30/2022 |
33333 | Lab tech | 02/10/2022 |
44444 | Sales | 02/01/2022 |
55555 | Proj. Man | 01/01/2022 |
66666 | Administr | 05/05/1999 |
77777 | Field Tech | 06/25/2015 |
88888 | Administr | 03/01/2022 |
99999 | Lab tech | 05/12/2022 |
your_data %>%
mutate(`Start Date` = as.Date(`Start Date`, "%m/%d/%Y")) %>%
filter(`Start Date` - Sys.Date() >= 90)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.