Skip to content

Instantly share code, notes, and snippets.

@dmarcelinobr
Created December 30, 2015 15:40
Show Gist options
  • Save dmarcelinobr/4c5be1fae0bf6bf87bfb to your computer and use it in GitHub Desktop.
Save dmarcelinobr/4c5be1fae0bf6bf87bfb to your computer and use it in GitHub Desktop.
Fingerprint two strings
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