pharmaverse / admiral

ADaM in R Asset Library
https://pharmaverse.github.io/admiral
Apache License 2.0
215 stars 60 forks source link

Documentation: derive_locf_records lose LOCF records. only 12 records there without any LOCF action #2461

Open WangLaoK opened 1 month ago

WangLaoK commented 1 month ago

Please select a category the issue is focused on?

Function Documentation

Let us know where something needs a refresh or put your idea here!

> # A tibble: 22 × 8

> STUDYID USUBJID PARAMCD PARAMN AVAL AVISITN AVISIT DTYPE

>

> 1 CDISC01 01-701-1015 DIABP 2 51 0 BASELINE NA

> 2 CDISC01 01-701-1015 DIABP 2 50 2 WEEK 2 NA

> 3 CDISC01 01-701-1015 DIABP 2 51 4 WEEK 4 NA

> 4 CDISC01 01-701-1015 DIABP 2 50 6 WEEK 6 NA

> 5 CDISC01 01-701-1015 PULSE 1 61 0 BASELINE NA

> 6 CDISC01 01-701-1015 PULSE 1 60 6 WEEK 6 NA

> 7 CDISC01 01-701-1015 SYSBP 3 121 0 BASELINE NA

> 8 CDISC01 01-701-1015 SYSBP 3 121 2 WEEK 2 NA

> 9 CDISC01 01-701-1015 SYSBP 3 121 4 WEEK 4 NA

> 10 CDISC01 01-701-1015 SYSBP 3 121 6 WEEK 6 NA

> # ℹ 12 more rows

Should have 12 more rows below, then user can see the LCOF creation there.

bms63 commented 1 month ago

Thank you @WangLaoK for the feedback!

@pharmaverse/admiral is there a way to display more of the rows in the examples?

manciniedoardo commented 1 month ago

Thank you @WangLaoK for the feedback!

@pharmaverse/admiral is there a way to display more of the rows in the examples?

Would print(dataset, n = 30) or similar work?

WangLaoK commented 1 month ago

Thank you @WangLaoK for the feedback! @pharmaverse/admiral is there a way to display more of the rows in the examples?

Would print(dataset, n = 30) or similar work?

Not sure if we can put LOCF record in the first 12 rows. please check the example in this link. https://pharmaverse.github.io/admiral/reference/derive_locf_records.html

manciniedoardo commented 1 month ago

Thank you @WangLaoK for the feedback! @pharmaverse/admiral is there a way to display more of the rows in the examples?

Would print(dataset, n = 30) or similar work?

Not sure if we can put LOCF record in the first 12 rows. please check the example in this link. https://pharmaverse.github.io/admiral/reference/derive_locf_records.html

{admiral} doesn't sort the output datasets usually. Maybe in the example we would need to combine print(dataset, n = 30) with a call to dplyr::arrange() to make the order more intutive.

bundfussr commented 1 month ago

I would change the subject ids such that the second subject is displayed first and sort the output dataset by USUBJID, PARAMCD, and AVISITN.

manciniedoardo commented 1 month ago

Hi @WangLaoK how come you closed this issue? I don't think we actioned it yet. I'm reopening it for now.

WangLaoK commented 1 month ago

Hi @WangLaoK how come you closed this issue? I don't think we actioned it yet. I'm reopening it for now.

Hi @manciniedoardo , sorry for the actions. I thought this query had been aware and solved from a new release.

I will not close issues next time. hope this is fine for you,.

Regards, Hans

jimrothstein commented 5 days ago

@manciniedoardo … what do I need to do finish this? #2461. Thx (also reading a lot re: pharmaverse)

manciniedoardo commented 5 days ago

@manciniedoardo … what do I need to do finish this? #2461. Thx (also reading a lot re: pharmaverse)

Will review, thanks for the reminder.

jimrothstein commented 5 days ago

I think now done. And it is better than mine! Still learning

@manciniedoardo

jimrothstein commented 8 minutes ago

Before I push again to #2475, I want to check this is right path: (intermediate variable X will NOT be in push)

Now:

As written, the example code must display all records to see LOCF populated in the DTYPE field. This might be a simple fix: (variable X is NOT appear in the push)

#' X= derive_locf_records(
#'   dataset = advs,
#'   dataset_ref = advs_expected_obsv,
#'   by_vars = exprs(STUDYID, USUBJID, PARAMCD),
#'   order = exprs(AVISITN, AVISIT),
#'   keep_vars = exprs(PARAMN)
#' )
#' X |> print(n=30)

Proposed

However, If I understand bundfussr's ... suggestion correctly, better to display USUBJID column first, followed by PARAMCD, AVISIT.

But this still requires printing all rows to see LOCF*, as follows: Proposed code (X will NOT appear in the push)

#' X |> relocate(USUBJID) |> arrange(USUBJID, PARAMCD, AVISIT) |> print(n=30)
#' X= derive_locf_records(
#'   dataset = advs,
#'   dataset_ref = advs_expected_obsv,
#'   by_vars = exprs(STUDYID, USUBJID, PARAMCD),
#'   order = exprs(AVISITN, AVISIT),
#'   keep_vars = exprs(PARAMN)
#' )
#'  #### X |> print(n=30)
#' X |> relocate(USUBJID) |> arrange(USUBJID, PARAMCD, AVISIT) |> print(n=30)

output from proposed solution

# A tibble: 22 × 8
   USUBJID     STUDYID PARAMCD PARAMN  AVAL AVISITN AVISIT   DTYPE
   <chr>       <chr>   <chr>    <dbl> <dbl>   <dbl> <chr>    <chr>
 1 01-701-1015 CDISC01 DIABP        2    51       0 BASELINE NA   
 2 01-701-1015 CDISC01 DIABP        2    50       2 WEEK 2   NA   
 3 01-701-1015 CDISC01 DIABP        2    51       4 WEEK 4   NA   
 4 01-701-1015 CDISC01 DIABP        2    50       6 WEEK 6   NA   
 5 01-701-1015 CDISC01 PULSE        1    61       0 BASELINE NA   
 6 01-701-1015 CDISC01 PULSE        1    60       6 WEEK 6   NA   
 7 01-701-1015 CDISC01 SYSBP        3   121       0 BASELINE NA   
 8 01-701-1015 CDISC01 SYSBP        3   121       2 WEEK 2   NA   
 9 01-701-1015 CDISC01 SYSBP        3   121       4 WEEK 4   NA   
10 01-701-1015 CDISC01 SYSBP        3   121       6 WEEK 6   NA   
11 01-701-1028 CDISC01 DIABP        2    79       0 BASELINE NA   
12 01-701-1028 CDISC01 DIABP        2    80       2 WEEK 2   NA   
13 01-701-1028 CDISC01 DIABP        2    80       4 WEEK 4   LOCF 
14 01-701-1028 CDISC01 DIABP        2    NA       4 WEEK 4   NA   
15 01-701-1028 CDISC01 DIABP        2    80       6 WEEK 6   LOCF 
16 01-701-1028 CDISC01 DIABP        2    NA       6 WEEK 6   NA   
17 01-701-1028 CDISC01 PULSE        1    65       0 BASELINE NA   
18 01-701-1028 CDISC01 PULSE        1    65       6 WEEK 6   LOCF 
19 01-701-1028 CDISC01 SYSBP        3   130       0 BASELINE NA   
20 01-701-1028 CDISC01 SYSBP        3   132       2 WEEK 2   NA   
21 01-701-1028 CDISC01 SYSBP        3   132       4 WEEK 4   LOCF 
22 01-701-1028 CDISC01 SYSBP        3   132       6 WEEK 6   LOCF