Created
December 15, 2020 00:29
-
-
Save mrdwab/24e3b933940cc0425c1b65d2f7e931af 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
# Using `fread` and `fwrite` to paste together columns like `do.call(paste, ...)` | |
fpaste <- function(dt, sep = ",") { | |
x <- tempfile() | |
if (sep == "") { | |
data.table(V1 = do.call(stringi::stri_join, c(dt, sep = ""))) | |
} else { | |
fwrite(dt, file = x, sep = sep, col.names = FALSE) | |
fread(x, sep = "\n", header = FALSE) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment