knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

RSOQuestions

RSOQuestions is a way to easily view / run the code of questions on the r tag on stackoverflow.

Installation

You can install RSOQuestions from GitHub with:

devtools::install_github("d-edison/RSOQuestions")

Example

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


d-edison/RSOQuestions documentation built on May 26, 2019, 2:30 a.m.