apache / apache/arrow

[R] Subtracting X days from a given date in ymd format

Open
#43,521 2 comments 0 reactions 0 assignees View on GitHub
Component: R Status: needs champion Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the usage question you have. Please include as many useful details as possible.

Hi Arrow developers.

I have seen topics on it in the feature requests, but I haven't found anything in the documentation yet suggesting how to do the following on an arrow pointer or table.

Lets say I wanted to filter my data to two points, thirty-days prior to a specific variable and another date.

However, it keeps throwing errors whenever I try to do the subtraction like so:
`data_pointer |> filter(between(ADate,(Initiation-30), Conclusion)) |> collect()`

Throwing:
```
Error in `compute.arrow_dplyr_query()`:
! NotImplemented: Function 'subtract_checked' has no kernel matching input types (struct, float)
Run `rlang::last_trace()` to see where the error occurred.
```

I tried some versions where I explicitly specified date format with subtraction:
`data_pointer |> filter(between(as.Date(ADate),(as.Date(Initiation)-arrow_subtract(30)), as.Date(Conclusion))) |> collect()`
`data_pointer |> filter(between(arrow_year_month_day(ADate),(arrow_year_month_day(Initiation)-arrow_subtract(day(30))), arrow_year_month_day(Conclusion))) |> collect()`

But they throw variations of:
```
Error in `compute.arrow_dplyr_query()`:
! NotImplemented: Function 'day' has no kernel matching input types (float)
Run `rlang::last_trace()` to see where the error occurred.
```

Would you be willing to provide a description of how to accomplish this?

Any help would be appreciated.

Thanks in advance!

### Component(s)

R

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.