| Title: | R Code Samples From Various Sources |
|---|---|
| Description: | Contains a database of code snippets from Github and Stack Overflow. |
| Authors: | David Hugh-Jones [aut, cre] |
| Maintainer: | David Hugh-Jones <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-16 06:06:56 UTC |
| Source: | https://github.com/hughjonesd/codesamples |
R snippets from Github.
github_datagithub_data
github_dataA data frame with 9,738 rows and 4 columns:
Starter for the github search
Github repo name
Path within the repo
The R snippet itself
These were created by using the github search API
with language:R and a "starter"
string chosen randomly from ls("package:base").
Obviously, don't run any code on your machine without checking it manually first!
R examples from 100 randomly chosen packages.
package_examplespackage_examples
package_examplesA data frame with 6,323 rows and 3 columns:
R package
Help topic
The R code itself
Unlike the other two datasets, example code should be reasonably safe. Still it is best to not run any code on your machine without checking it manually first!
R snippets from Stack Overflow questions.
so_questionsso_questions
so_questionsA data frame with 11,013 rows and 3 columns:
SO post ID
Question creation date
The R code itself
Questions were from 2013 onwards, with a
minimum score of 3 and the R tag.
Note that not all code that parses is guaranteed
to be valid R. For example, a R DESCRIPTION file
may parse as R code.
Obviously, don't run any code on your machine without checking it manually first!
Here is the original SQL query on <data.stackexchange.com>:
SELECT DISTINCT
p.Id,
p.PostTypeId,
p.Body,
p.CreationDate
FROM
Posts p
INNER JOIN PostTags pt ON p.Id = pt.PostId
INNER JOIN Tags t ON pt.TagId = t.Id
WHERE
(UPPER(t.TagName) LIKE UPPER('R'))
AND
(p.Score >= 3)
AND
(p.CreationDate > '2013-01-01')