Created
December 30, 2015 15:40
-
-
Save dmarcelinobr/4c5be1fae0bf6bf87bfb to your computer and use it in GitHub Desktop.
Fingerprint two strings
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
| fingerprint <- function(x, y) { | |
| if (!inherits(x, "character") | !inherits(y, "character")) { | |
| stop("x and y must be character strings") | |
| } | |
| x1 <- strsplit(x, "")[[1]] | |
| y1 <- strsplit(y, "")[[1]] | |
| f <- c(x1, y1) | |
| final <- paste(f[order(f)], collapse = "") | |
| return(final) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment