knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
RSOQuestions is a way to easily view / run the code of questions on the r
tag on stackoverflow.
You can install RSOQuestions from GitHub with:
devtools::install_github("d-edison/RSOQuestions")
You can grab a question from stackoverflow by using the get_question
function and providing a question ID (found in the URL of the question):
library(RSOQuestions) # this ID corresponds to a popular question on the differences between <- and = for assignment q <- get_question(id = 1741820)
If no arguments are provided to get_question
, the most recent question on the r
tag will be used by default. RSOQuestions also provides a convenience function get_recent_ids
to grab the 30 most recent IDs on the r
tag:
get_recent_ids()
To view the question in the RStudio Viewer pane, use view_question
:
view_question(q)
You run anything formatted as code with run_code
. This function will run all expressions in the global environment and capture all results and errors:
# run all code in global environment res <- run_code(q) # see results res
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.