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

Feature Request: Enhance derive_locf_records() #2694

Open
bundfussr opened this issue Mar 18, 2025 · 3 comments
Open

Feature Request: Enhance derive_locf_records() #2694

bundfussr opened this issue Mar 18, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request programming

Comments

@bundfussr
Copy link
Collaborator

Feature Idea

derive_locf_records() should be enhanced such that it works when analysis visits are assigned based on time windows.

Relevant Input

No response

Relevant Output

No response

Reproducible Example/Pseudo Code

library(dplyr)
adbs <- tribble(
  ~AVISITN, ~ADY,  ~AVAL,
  1,           1,  10,
  2,           8,  12,
  3,          15,  10,
  3,          17,  14,
  5,          29,  13
) %>%
  mutate(USUBJID = "1")

visit_ref = tribble(
  ~AVISITN, ~ADY,
  1,           1,
  2,          12,
  3,          19,
  4,          26,
  5,          33
)

The expected result is:

  AVISITN   ADY  AVAL USUBJID DTYPE
    <dbl> <dbl> <dbl> <chr>   <chr>
1       1     1    10 1       NA   
2       2     8    12 1       NA   
3       3    15    10 1       NA   
4       3    17    14 1       NA   
5       4    26    14 1       LOCF 
6       5    29    13 1       NA   

This can't be produced by the current version of derive_locf_records() because all variables in the reference dataset are considered when determining whether a visit is available or not. For example,

derive_locf_records(
  adbs,
  dataset_ref = visit_ref,
  by_vars = exprs(USUBJID),
  order = exprs(ADY)
)

produces

# A tibble: 9 × 5
  AVISITN   ADY  AVAL USUBJID DTYPE
    <dbl> <dbl> <dbl> <chr>   <chr>
1       1     1    10 1       NA   
2       2     8    12 1       NA   
3       2    12    12 1       LOCF 
4       3    15    10 1       NA   
5       3    17    14 1       NA   
6       3    19    14 1       LOCF 
7       4    26    14 1       LOCF 
8       5    29    13 1       NA   
9       5    33    13 1       LOCF 
@bms63
Copy link
Collaborator

bms63 commented Mar 18, 2025

@gg106046 any chance you want to have a go at this update for your function?

@gg106046
Copy link
Contributor

@gg106046 any chance you want to have a go at this update for your function?

Hi @bms63, sure! I can take this up!

@gg106046 gg106046 self-assigned this Mar 19, 2025
@bms63
Copy link
Collaborator

bms63 commented Mar 21, 2025

Awesome thanks @gg106046 !!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request programming
Development

No branches or pull requests

3 participants