Skip to content

Instantly share code, notes, and snippets.

@smbache
Created August 11, 2014 12:46
Show Gist options
  • Save smbache/7f9bec0b33ecd67c36c2 to your computer and use it in GitHub Desktop.
Save smbache/7f9bec0b33ecd67c36c2 to your computer and use it in GitHub Desktop.
`<<`
`%<<%` <- 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