Description Usage Arguments Value Author(s) Examples
Runs the R code, captures both code and output and prints such that code and output are readily copied into an Stack Overflow post or answer. I.e. it prefixes four spaces and (optinally) comments output.
1 | formatForStackOverflow(user_code, comment_eval = TRUE, file = "")
|
user_code |
A character of length 1 of user code to run and format. |
comment_eval |
logical. If |
file |
A path to a file to write the output to. The default prints to console. |
Prints to console or file a ready-to-copy to Stack Overflow formatted code and output.
Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 | formatForStackOverflow("
myfunc <- function(x) {
return(c(mean=mean(x), med=median(x)))
}
# A comment
n <- 100
myfunc(rnorm(n))
sapply(mtcars, myfunc) # inline comment
print(mtcars)
")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.