datamods
datamods copied to clipboard
Cannot currently update a variable's class to "ordinal"
The ability to change a variable to an ordinal factor is sorely missing in the current implementation of update tab of the datamods::import_server()
module. This is not optional in the case of ordinal regression (i.e. ordinal target) or in the case of dummy encoding of ordinal predictors. Ordinal factors need to have a human-curated sequence of levels defined.
This would involve a sub-dialogue to determine the order of the factor levels. I think a selectize control (with multiple = true
) would suffice in the short term but better dialogues can be imagined.
Ideally this would be a modal dialogue BUT this is problematic if the update process is already in a modal dialogue as would be the case with datamods::import_modal()
. Some clever reuse of the existing modal dialogue would be required to emulate modal-within-modal. Alternatively the update-table could have an extra column for defining the ordinal sequence.
Either way this would be a welcome addition to the package.
Hello,
We are going to add a separate module to order levels of a factor variable.
In module update-variable
we can order
as a choice and apply as.ordered()
on the factor as is and then reorder levels afterwards with the new module.
Great news that you want to make this enhancement. I think it would be a good idea to correct the order of factor levels at the same time as migrating the character (or factor) variable to an ordinal factor. Otherwise, you risk only doing part of the job. Perhaps your plan is: only to factor
is available in the existing dialogue and the ability to transform factors to ordinal factors
happens in a separate dialogue that includes the ordering of levels.
I would be grateful for any implementation.
Aside:
Converting row-names
into a variable is something that could (even should) be undertaken in your module. This is particularly relevant when using package datasets that employ row-names
as observation identifiers. While not critical, this is an easy enhancement to implement.
Keep up the good work.