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: Implement transform_range() #2571

Open
manciniedoardo opened this issue Nov 19, 2024 · 2 comments
Open

Feature Request: Implement transform_range() #2571

manciniedoardo opened this issue Nov 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers programming

Comments

@manciniedoardo
Copy link
Collaborator

manciniedoardo commented Nov 19, 2024

Feature Idea

From suggestion by @bundfussr:

to help with ADQS programming, it would be convenient to implement a function which provides the same transformation arguments as compute_scale():

transform_range <- function(value,
                            source_range = NULL,
                            target_range = NULL,
                            flip_direction = FALSE,
                            outside_range = "NA"
)

The outside_range argument determines how values outside the source range are handled. Options are setting to NA, issuing an error, or issuing a warning. (The new function could also be called by compute_scale().) I would expect that it could be useful for other questionnaires as well.

Relevant Input

See here for compute_range() inputs.

Relevant Output

A transformed value

Reproducible Example/Pseudo Code

transform_range(
  value = 2,
  source_range = c(1:5),
  target_range = c(0:100),
  flip_direction = FALSE,
  outside_range = NA
)

Should return 25.

transform_range(
  value = 3,
  source_range = c(1:6),
  target_range = c(0:100),
  flip_direction = TRUE,
  outside_range = NA
)

Should return 60 i.e. 100 - 40.

transform_range(
  value = 300,
  source_range = c(1:6),
  target_range = c(0:100),
  flip_direction = TRUE,
  outside_range = NA
)

Should return NA.

@manciniedoardo
Copy link
Collaborator Author

@bundfussr please double check logic above, thanks

@bundfussr
Copy link
Collaborator

@bundfussr please double check logic above, thanks

@manciniedoardo , looks good to me. Thanks for creating the issue.

@bundfussr bundfussr self-assigned this Nov 21, 2024
@bundfussr bundfussr changed the title Feature Request: <Insert Issue Title Here> Feature Request: Implement transform_range() Nov 21, 2024
@bundfussr bundfussr moved this from Backlog to In Progress in admiral (sdtm/adam, dev, ci, template, core) Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers programming
Development

No branches or pull requests

2 participants