A common need is to aggregate a data.frame to create column means (or medians), but appropriately handle factor, logical, and other non-numeric variable classes (i.e., aggregate to their mode rather than their [undefined] mean/median). A common use case for this is getting something like the "average prediction" or "marginal effect at means" (MEM).
I don't really want to implement either of those things specifically, but having a function to do them can be useful. For example, I have a function for this internally in margins::cplot():
A common need is to aggregate a data.frame to create column means (or medians), but appropriately handle factor, logical, and other non-numeric variable classes (i.e., aggregate to their mode rather than their [undefined] mean/median). A common use case for this is getting something like the "average prediction" or "marginal effect at means" (MEM).
I don't really want to implement either of those things specifically, but having a function to do them can be useful. For example, I have a function for this internally in
margins::cplot()
:I should move it here, make it a bit more robust, and export it. Then call it from
cplot()
.