Skip to content

Instantly share code, notes, and snippets.

@RCura
Created July 29, 2013 16:18
Show Gist options
  • Select an option

  • Save RCura/6105510 to your computer and use it in GitHub Desktop.

Select an option

Save RCura/6105510 to your computer and use it in GitHub Desktop.
function (output = stdout(), envir = parent.frame())
{
sunk <- FALSE
if (!missing(output)) {
sunk <- TRUE
sink(output)
}
text <- get("text")
brew.cat <- function(from, to) cat(text[from:to], sep = "",
collapse = "")
.prev.brew.cat <- NULL
if (exists(".brew.cat", envir = envir)) {
.prev.brew.cat <- get(".brew.cat", pos = envir)
}
assign(".brew.cat", brew.cat, envir = envir)
code <- get("code")
ret <- try(eval(code, envir = envir))
if (sunk && unclass(output) != 1)
sink()
if (!is.null(.prev.brew.cat)) {
assign(".brew.cat", .prev.brew.cat, envir = envir)
}
else {
rm(".brew.cat", envir = envir)
}
invisible(ret)
}
<environment: 0x604fed0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment