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

Should type_function() be y aware? #257

Open
grantmcdermott opened this issue Nov 15, 2024 · 1 comment
Open

Should type_function() be y aware? #257

grantmcdermott opened this issue Nov 15, 2024 · 1 comment

Comments

@grantmcdermott
Copy link
Owner

It would be cool if we could do something like:

plt(
    weight ~ Time | Diet, data = ChickWeight,
    type = type_function(\(x, y) ave(y, x))
)

Where, in this case, you would get lines of the mean weight per Time period. You'd have to check that the resulting object was the same length as the original object, though.

OTOH maybe this should be a separate type function (type_summary?) that explicitly guarantees the same length by passing appropriate summary functions to ave. Then you could do things like:

plt(
    weight ~ Time | Diet, data = ChickWeight,
    type = type_summary(fun = mean) # or median etc.
)
@vincentarelbundock
Copy link
Collaborator

That feels like a different type. Maybe something like type_transform(fun), where we would check formals(fun) to see if we should pass it x, y, ymin, ymax, etc. I can imagine, for example, using this to back-transform confidence intervals, so transforming ymin might be useful too.

Would have to think about what constraints to impose on input/output. If we go such a flexible route, I think it should be very strict and raise informative errors. Otherwise users will get frustrated with weird messages.

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

No branches or pull requests

2 participants