Created
August 11, 2014 12:46
-
-
Save smbache/7f9bec0b33ecd67c36c2 to your computer and use it in GitHub Desktop.
`<<`
This file contains 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
`%<<%` <- function(con, x) | |
{ | |
UseMethod("%<<%", x) | |
} | |
`%<<%.function` <- function(con, x) | |
{ | |
if (!identical(x, close)) | |
stop("Unknown function provided to <<", call. = FALSE) | |
close(con) | |
} | |
`%<<%.character` <- function(con, x) | |
{ | |
file <- if (is.character(con)) file(con, open = "a") else con | |
cat(x, file = file) | |
invisible(file) | |
} | |
`%<<%.data.frame` <- function(con, x) | |
{ | |
file <- if (is.character(con)) file(con, open = "a") else con | |
nm <- summary(file)$description | |
write.table(x, | |
file = file, | |
row.names = FALSE, | |
col.names = FALSE) | |
invisible(file) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment