Last active
January 29, 2023 21:48
-
-
Save danlewer/a473b1f871f0fa55ea0201e4c1187fc4 to your computer and use it in GitHub Desktop.
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
# return a table, but specify the values you want to be tabulated | |
# works like base::table, but supplies only specified values, and returns 0 if none of those values exist in the vector | |
tab_specific_values <- function(vector, values = unique(vector)) `names<-`(rowSums(outer(values, vector, `==`)), values) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment