Skip to content

Comments

Added support for recoding custom variables#24

Merged
reikookamoto merged 3 commits intocustom-variablefrom
custom-variables-imp
Jan 3, 2024
Merged

Added support for recoding custom variables#24
reikookamoto merged 3 commits intocustom-variablefrom
custom-variables-imp

Conversation

@yulric
Copy link
Collaborator

@yulric yulric commented Dec 15, 2022

Files Changes

  • recode_with_table.R - Updated to add support for custom variables
  • test-custom-variables.R - New test file for custom variables
  • strings.R - New strings for the custom variable column

no_custom_variables_variable_details <- variable_details
# If the custom variable isn't in the variable details sheet then this
# is a pre custom variable sheet. Don't run the code.
if(variable_details_columns$custom_variable$name %in% colnames(variable_details)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yulric variable_details_columns in which line is this variable defined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes from these lines in strings.R.

You probably have more insight into this but what's the best way to use variables from other files? Do you just source that file or call it from the package namespace, so recodeflow:::variable_details_columns?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continuing this discussion in #32

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a more general note, why is it necessary to manually create a new environment and bind names to strings?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It isn't and we've moved away from that in new code.

We started doing this because we were not sure about the R convention regarding the declaration of non-function variables in a package but since realized it does not add any value to store them in a separate environment.

This file requires quite a bit of refactoring....

Problem:
- customVariable feature needed a more descriptive name

Solution:
- replace all instances with templateVariable in both code and comments

Files changed:
- R/recode-with-table.R
- R/strings.R
- tests/testthat/test-custom-variables.R
@reikookamoto reikookamoto merged commit eee748c into custom-variable Jan 3, 2024
@reikookamoto reikookamoto deleted the custom-variables-imp branch January 3, 2024 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants