diff --git a/R/io.R b/R/io.R index 917c62e..11477da 100644 --- a/R/io.R +++ b/R/io.R @@ -795,14 +795,12 @@ write_gmt <- function(lst, fname) { # head, desc, entry if (file.exists(fname)) { message(paste(fname, "exists, deleting...")) - file.remove(fname) - } - for (i in seq_along(lst)) { - el <- lst[[i]] - ncolumns <- 2 + length(el$entry) - write(c(el$head, el$desc, el$entry), file=fname, sep="\t", - append=TRUE, ncolumns=ncolumns) + # fname will be overwritten by cat() } + lst <- vapply(lst, function(el) { + paste(c(el$head, el$desc, el$entry), collapse = "\t") + }, character(1L)) + cat(lst, file=fname, sep="\n", append=FALSE) } #' Read an LXB file and return a matrix