codesamples

R Code Samples From Various Sources

OTHER License

Stars
11

output: github_document

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

codesamples

A large database of R snippets from Stack Overflow, Github and package examples.

Installation

You can install the development version of codesamples from GitHub with:

# install.packages("remotes")
remotes::install_github("hughjonesd/codesamples")

Example

library(codesamples)
dim(github_data)
dim(so_questions)
dim(package_examples)

first_lines <- strsplit(github_data$snippet[[1]], "\n")[[1]][1:23] 
cat(first_lines, sep = "\n")

cat(package_examples$snippet[[1]])

cat(so_questions$snippet[[1]])