Skip to content

Instantly share code, notes, and snippets.

@tylerlittlefield
Last active March 10, 2019 19:50
Show Gist options
  • Save tylerlittlefield/7b2f0ec8ccad0cdac521ef5f51833ada to your computer and use it in GitHub Desktop.
Save tylerlittlefield/7b2f0ec8ccad0cdac521ef5f51833ada to your computer and use it in GitHub Desktop.
For question about vectorization
rx_literal2 <- function(.data = NULL, ... ) {
stopifnot(
length(unique(sapply(list(...), length))) == 1
)
args <- sapply(list(...), function(x) if(inherits(x, "rx_string")) x else sanitize(x))
apply(args, 1, paste, collapse="")
}
rx_literal2(c("!", "@"), c("abc", "!"))
#> [1] "!abc" "@!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment