Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make .extract_surv_time() work correctly for 1-row output #1027

Merged
merged 2 commits into from
Nov 20, 2023
Merged

Conversation

EmilHvitfeldt
Copy link
Member

to close #1025

times <- seq(1, 100, length.out = 5)
times2 <- seq(100, 200, length.out = 5)
events <- c(1, 0, 1, 0, 1)

intv_c <- survival::Surv(times, times2, events, type = "interval")
count_c <- survival::Surv(times, times2, events)

parsnip:::.extract_surv_time(intv_c[1])
#> # A tibble: 2 × 1
#>     res
#>   <dbl>
#> 1     1
#> 2     1

parsnip:::.extract_surv_time(count_c[1])
#> # A tibble: 2 × 1
#>     res
#>   <dbl>
#> 1     1
#> 2   100

Created on 2023-11-17 with reprex v2.0.2

hfrick
hfrick approved these changes Nov 20, 2023
@hfrick hfrick self-requested a review November 20, 2023 18:33
@hfrick
Copy link
Member

hfrick commented Nov 20, 2023

Geez, the reprex had me panic for a moment 😂 but that is not what happen here now!

times <- seq(1, 100, length.out = 5)
times2 <- seq(100, 200, length.out = 5)
events <- c(1, 0, 1, 0, 1)

intv_c <- survival::Surv(times, times2, events, type = "interval")
count_c <- survival::Surv(times, times2, events)

parsnip:::.extract_surv_time(intv_c[1])
#> # A tibble: 1 × 2
#>   time1 time2
#>   <dbl> <dbl>
#> 1     1     1

parsnip:::.extract_surv_time(count_c[1])
#> # A tibble: 1 × 2
#>   start  stop
#>   <dbl> <dbl>
#> 1     1   100

Created on 2023-11-20 with reprex v2.0.2

So, original point still stands: Looks good! Approved! ✅ Could you just add the bump in version number for the tests in tidymodels/extratests#148?

@EmilHvitfeldt EmilHvitfeldt merged commit e809d0f into main Nov 20, 2023
@EmilHvitfeldt EmilHvitfeldt deleted the fix-1025 branch November 20, 2023 21:52
Copy link

github-actions bot commented Dec 5, 2023

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.extract_surv_time() should return 1-row tibble for single observation with interval or counting censoring
2 participants