`sf <- sf |>
dplyr::select(n_number, s_date) |>
dplyr::filter( s_date == mean(s_date), .by = n_number)`
There was 1 warning in dplyr::filter()
.ℹ In argument: s_date == mean(s_date)
.Caused by warning in mean.default()
:! argument is not numeric or logical: returning NA
I try to find out the first occurance date for each s_number.
The data is like this
| n_number | s_date |
| ——– | ——– |
| 1 | 2024-05-28 |
| 1 | 2024-05-25 |
| 2 | 2024-03-28 |
| 2 | 2024-04-25 |
| 3 | 2023-05-25 |
I want the output to like this
Column A | Column B |
---|---|
1 | 2024-05-25 |
2 | 2024-03-28 |
3 | 2023-05-25 |
I tried to use dplyr filter to find the eariest date using mean() function, but it give the error above.
ktw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.