Package 'codesamples'

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: 2024-07-03 14:23:17 UTC
Source: https://github.com/hughjonesd/codesamples

Help Index


Github R Snippets

Description

R snippets from Github.

Usage

github_data

Format

github_data

A data frame with 9,738 rows and 4 columns:

starter

Starter for the github search

repo

Github repo name

path

Path within the repo

snippet

The R snippet itself

Details

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!


Package examples

Description

R examples from 100 randomly chosen packages.

Usage

package_examples

Format

package_examples

A data frame with 6,323 rows and 3 columns:

package

R package

topic

Help topic

snippet

The R code itself

Details

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!


Stack Overflow R Snippets

Description

R snippets from Stack Overflow questions.

Usage

so_questions

Format

so_questions

A data frame with 11,013 rows and 3 columns:

post_id

SO post ID

creation_date

Question creation date

snippet

The R code itself

Details

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')