Parrot the input expression and append the output with knitr-style comments, all as markdown. soanswer changes the output for a single expression.

soanswer(expr, in_task_callback = FALSE)

Arguments

expr

An R expression.

in_task_callback

A logical value. Not intended for direct use.

Value

Markdown output is printed to the console, written to the clipboard and silently returned as a noquote character vector.

See also

Author

Richard Cotton

Examples

# Output for various types, explicitly calling soanswer soanswer(sin(2 * pi))
#> sin(2 * pi) #> ## [1] -2.449294e-16
soanswer(sleep)
#> sleep #> ## extra group ID #> ## 1 0.7 1 1 #> ## 2 -1.6 1 2 #> ## 3 -0.2 1 3 #> ## 4 -1.2 1 4 #> ## 5 -0.1 1 5 #> ## 6 3.4 1 6 #> ## 7 3.7 1 7 #> ## 8 0.8 1 8 #> ## 9 0.0 1 9 #> ## 10 2.0 1 10 #> ## 11 1.9 2 1 #> ## 12 0.8 2 2 #> ## 13 1.1 2 3 #> ## 14 0.1 2 4 #> ## 15 -0.1 2 5 #> ## 16 4.4 2 6 #> ## 17 5.5 2 7 #> ## 18 1.6 2 8 #> ## 19 4.6 2 9 #> ## 20 3.4 2 10
soanswer(message("A message!"))
#> message("A message!") #> ## A message!
soanswer(warning("A warning!"))
#> warning("A warning!") #> ## Warning message: #> ## A warning!
soanswer(stop("An error!"))
#> stop("An error!") #> ## Error: An error!