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

Create derive_var_bvcacritxfl function #49

Closed
manciniedoardo opened this issue Jan 4, 2023 · 2 comments
Closed

Create derive_var_bvcacritxfl function #49

manciniedoardo opened this issue Jan 4, 2023 · 2 comments

Comments

@manciniedoardo
Copy link
Collaborator

manciniedoardo commented Jan 4, 2023

Background Information

Create function derive_var_bcvacritxfl which can create criterion flags for CBVA gain/loss of x letters. Functionality could be as follows:

derive_var_bcvacritxfl <- function(
  ...
  gain_values,
  lose_values,
  ....
){
<function code>
}

which could be called like this:

adbcva <- adbcva %>% 
    derive_var_bcvacritxfl(
        gain_values = c(10,15),
        lose_values = c(5,10)
     )

to generate an updated ADBCVA dataset containing criterion flags CRIT1FL, CRIT2FL, CRIT3FL, CRIT4FL for gaining 10 letters, gaining 15 letters, losing 5 letter and losing 10 letters respectively, along with associated variables CRIT1, CRIT2, CRIT3, CRIT4 encoding the criterion for the flag (eg, CRIT1 = "10 letter BCVA gain" for BCVA records and blank otherwise).

Proposed convention:

  • CRITxFL with 1<=x<=10 used for BCVA gain categories
  • CRITxFL with 11<=x<20 used for BCVA loss categories

This will be quite a central function in {admiralophtha}, so we should aim to provide:

  • many examples in the function roxygen code
  • vignette
  • example in the ADBCVA template.

Note: we should also add avoidloss_values and avoidgain_values corresponding to avoiding a loss/gain of x letters. An appropriate convention can also be considered like the one suggested above.

@ukey1025
Copy link
Collaborator

ukey1025 commented Jan 31, 2023

Sorry for my delay coding. I missed push my branch so copy my code here.

I have some questions.
i) Do gain_values and loss_values always have 2 vectors? If not, I need to modify code which.
ii) Sorry for I am not famillier with ADBCVA, how to define gain_values or loss _values. Do we usulally use minus numbers?

I will confirm with our in-house ophthalmologist tomorrow, and will modify.

/////

derived_var_bvcacritxfl <- function(
    adbcva_1,
    x,
    gain_values,
    lose_values
){
  
  adbcva_1 %>%
    mutate(CRIT1FL = ifelse((!!as.name(x) >= gain_values[1] & !!as.name(x) < gain_values[2]),
                            paste(gain_values[1], " letter BCVA gain"), "" )) %>%
    mutate(CRIT2FL = ifelse((!!as.name(x) >= gain_values[2]),
                            paste(gain_values[2], " letter BCVA gain"), "" )) %>%  
    mutate(CRIT3FL = ifelse((!!as.name(x) <= -(lose_values[1] & !!as.name(x) < -(lose_values[2])),
                            paste(lose_values[1], " letter BCVA loss"), "" )) %>%
    mutate(CRIT4FL = ifelse((!!as.name(x) <= -(lose_values[2])),
                            paste(lose_values[2], " letter BCVA loss"), "" ))
}

@manciniedoardo manciniedoardo self-assigned this Feb 1, 2023
@manciniedoardo
Copy link
Collaborator Author

Thanks for this Yuki. A couple of notes:

  • We really should be working in a separate branch, so I will make a new branch and copy the code across.
  • We should be following the programming strategy listed here, which has info about variable names and formatting.
  • I think it would make sense to loop over gain_values and lose_values rather than having many mutate statements.

I am happy to implement the above myself and then circle back with you to show you what I've done and how I've done it 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants