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

Use custom class in internal representation #16

Open
EmilHvitfeldt opened this issue Feb 2, 2024 · 2 comments
Open

Use custom class in internal representation #16

EmilHvitfeldt opened this issue Feb 2, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@EmilHvitfeldt
Copy link

Great package!

I would recommend that you use a custom class internally to handle the measure column. It doesn't have to do much, just enough that you can do inherits(x, "measure_obj"). This will save you some headache in the long run.

So steps like step_measure_input_*() produces this class type. This automatically gives the benefit that you don't have to worry about name clashes as it is dependent on the class, not name of column.

All the remaining steps can then use the class.

A function like check_has_measure() can do any(inherits(x, "measure_obj")). You also get the flexibility to easily have multiple measure columns, as talked about in #13.

@JamesHWade
Copy link
Owner

Thank you for the suggestion! I'll give that a try.

@JamesHWade JamesHWade added the enhancement New feature or request label Feb 2, 2024
@topepo
Copy link
Collaborator

topepo commented Feb 18, 2024

We were talking about this in our group meeting (and I think I discussed it with Hadley). If we make a specialized vector class, we could also give the vector a slot that contains all possible location (i.e. x) values across all of the samples. This would be sort of like how a factor keeps all possible factor levels.

The vctrs package makes it fairly easy to do (here is an example).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants