Created
April 16, 2020 14:21
-
-
Save seasmith/07971958efabf77d705685688197cc7a to your computer and use it in GitHub Desktop.
Last value per group
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Produces an 'unmatched length' error | |
last_by_group <- function (x, group = NULL, order_by = NULL, default = default_missing(x)) { | |
if (is.null(group)) { | |
return(last(x, order_by = order_by, default, default)) | |
} else { | |
tapply(X = x, INDEX = group, FUN = last) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment