-
Notifications
You must be signed in to change notification settings - Fork 9
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
Don't overwrite label, width, or sas.format in xportr_type()
#85
Conversation
Fixes issue #75 by retaining column attributes (such as label). Tested with `xportr_label()` only, not with `metacore::set_variable_labels()` (is that even a real function?)
Now that `xportr_type()` is not overwriting column labels, applying it before or after `xportr_label()` should make no difference
In general, setting the type for each column should retain each column's attributes, such as label, width, and sas.format. These are set by other xportr functions. However, in cases where a column in the input dataset has a class already, such as a Date or a factor, this attribute should be dropped from the column. If it is not, it causes an error
Codecov Report
@@ Coverage Diff @@
## devel #85 +/- ##
==========================================
+ Coverage 66.00% 74.93% +8.93%
==========================================
Files 10 10
Lines 350 375 +25
==========================================
+ Hits 231 281 +50
+ Misses 119 94 -25
... and 4 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@EeethB can you have this go into the devel branch. @elimillera can you make it so that branches that are merged into devel are deleted ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is minor - but can we also put a quick blurb in the New.md file. Just good habit so we aren't doing this at the release.
Comments have been added to NEWS.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@elimillera can you just once over this as well please?? |
Fixes #75
The issue here was that coercing columns with
as.character()
oras.numeric()
strips all attributes, not just the class attribute that we want to be rid of. I made a change to save attributes besides class (such as width, label, and format.sas), then restore those classes after coercion. I also wrote a test that checks for identical results whetherxportr_type()
is called at the beginning or end of a pipeline.The function
metacore::set_variable_labels()
was also referenced in the original issue. I cannot find such a function in metacore, so I have not tested against it here. If it sets labels with an attribute like xportr does, this will fix it as well.Should I ask the original issue filer to install this version for testing?
Please let me know if there's anything you want changed or included in this PR!