简体   繁体   中英

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

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. Additionally I would like for this employee to be left out of consideration until the 1st of the following month. So basically exclude employees until the 1st of the month following their 90th day after hire . 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).

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM