Rclean

Rclean: A Tool for Writing Cleaner, More Transparent Code - Published in JOSS (2020)

https://github.com/ropensci-archive/Rclean

Science Score: 46.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    2 of 4 committers (50.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (21.6%) to scientific vocabulary

Scientific Fields

Sociology Social Sciences - 64% confidence
Last synced: 4 months ago · JSON representation

Repository

:warning: ARCHIVED :warning: Isolate essential code to re-produce specific results.

Basic Info
  • Host: GitHub
  • Owner: ropensci-archive
  • License: gpl-3.0
  • Language: TeX
  • Default Branch: master
  • Homepage:
  • Size: 9.18 MB
Statistics
  • Stars: 94
  • Watchers: 8
  • Forks: 13
  • Open Issues: 0
  • Releases: 13
Archived
Created over 8 years ago · Last pushed about 3 years ago
Metadata Files
Readme Changelog Contributing License Code of conduct Codemeta

README-not.md

Build
Status Coverage
status

CRAN\_Status\_Badge RStudio CRAN
downloads RStudio CRAN monthly
downloads Rdocumentation

Project Status: Active – The project has reached a stable, usable
state and is being actively
developed. lifecycle

status

DOI

Quick Start Guide

  • Rclean was created to help scientists more easily write “cleaner” code.
  • Written with research scientists that are results oriented in mind, the package’s primary function provides a simple way to isolate the minimal code you need to produce a specific result, such as a statistical table or a figure. By focusing on specific results (aka. variables), large and/or complicated analytical scripts can be paired down to the essentials and easily re-factored to be more robust and easily shared.
  • Below, you'll find a brief introduction to get you started using the package. For more details, see vignette("Rclean").

Install

You can install the most up to date version easily with devtools:

install.packages("devtools")
devtools::install_github("MKLau/Rclean")

You will also likely need to install the RGraphViz:

install.packages("BiocManager")
BiocManager::install("Rgraphviz")

Once installed, per usual R practice just load the Rclean package with:

library(Rclean)

Usage

Rclean usage is simple. Have a script with code you want to clean saved to disk. Then, just run the clean function with the path to the script as the input. Here, we can use an example script that is included with the package:

script <- system.file("example", "simple_script.R", package = "Rclean")

Here's a quick look at the code:

readLines(script)
#>  [1] "## Make a data frame"                             
#>  [2] "mat <- matrix(rnorm(400), nrow = 100)"            
#>  [3] "dat <- as.data.frame(mat)"                        
#>  [4] "dat[, \"V2\"] <- dat[, \"V2\"] + runif(nrow(dat))"
#>  [5] "dat[, \"V5\"] <- gl(10, 10)"                      
#>  [6] "## Conduct some analyses"                         
#>  [7] "fit12 <- lm(V1 ~ V2, data = dat)"                 
#>  [8] "fit13 <- lm(V1 ~ V3, data = dat)"                 
#>  [9] "fit14 <- lm(V1 ~ V4, data = dat)"                 
#> [10] "fit15.aov <- aov(V1 ~ V2 + V5, data = dat)"       
#> [11] "## Summarize analyses"                            
#> [12] "summary(fit15.aov)"                               
#> [13] "tab.12 <- summary(fit12)"                         
#> [14] "tab.13 <- summary(fit13)"                         
#> [15] "tab.14 <- summary(fit14)"                         
#> [16] "tab.15 <- append(fit15.aov, tab.14)"              
#> [17] "## Conduct a calculation"                         
#> [18] "dat <- 25 + 2"                                    
#> [19] "dat[2] <- 10"                                     
#> [20] "out <- dat * 2"

You can get a list of the variables found in an object with get_vars.

get_vars(script)
#>  [1] "mat"       "dat"       "fit12"     "fit13"     "fit14"     "fit15.aov"
#>  [7] "tab.12"    "tab.13"    "tab.14"    "tab.15"    "out"

Sometimes for more complicated scripts, it can be helpful to see a network graph showing the interdependencies of variables. code_graph will produce a network diagram showing which lines of code produce or use which variables:

code_graph(script)

Now, we can pick the result we want to focus on for cleaning:

clean(script, "tab.15")
#> mat <- matrix(rnorm(400), nrow = 100)
#> dat <- as.data.frame(mat)
#> dat[, "V2"] <- dat[, "V2"] + runif(nrow(dat))
#> dat[, "V5"] <- gl(10, 10)
#> fit14 <- lm(V1 ~ V4, data = dat)
#> fit15.aov <- aov(V1 ~ V2 + V5, data = dat)
#> tab.14 <- summary(fit14)
#> tab.15 <- append(fit15.aov, tab.14)
#> dat <- 25 + 2
#> dat[2] <- 10

We can also select several variables at the same time:

my.vars <- c("tab.12", "tab.15")
clean(script, my.vars)
#> mat <- matrix(rnorm(400), nrow = 100)
#> dat <- as.data.frame(mat)
#> dat[, "V2"] <- dat[, "V2"] + runif(nrow(dat))
#> dat[, "V5"] <- gl(10, 10)
#> fit12 <- lm(V1 ~ V2, data = dat)
#> fit14 <- lm(V1 ~ V4, data = dat)
#> fit15.aov <- aov(V1 ~ V2 + V5, data = dat)
#> tab.12 <- summary(fit12)
#> tab.14 <- summary(fit14)
#> tab.15 <- append(fit15.aov, tab.14)
#> dat <- 25 + 2
#> dat[2] <- 10

While just taking a look at the simplified code can be very helpful, you can also save the code for later use or sharing (e.g. creating a reproducible example for getting help) with keep:

my.code <- clean(script, my.vars)
keep(my.code, file = "results_tables.R")

If you would like to copy your code to your clipboard, you can do that by not specifying a file path. You can now paste the simplified as needed.

keep(my.code)

Contributing

This is an open-source project. If you would like to contribute to the project, please check out CONTRIBUTING.md.

Please note that the 'Rclean' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

ropensci\_footer

Owner

  • Name: rOpenSci Archive
  • Login: ropensci-archive
  • Kind: organization
  • Email: info@ropensci.org

Abandoned rOpenSci projects -- email info@ropensci.org if you have questions!

CodeMeta (codemeta.json)

{
  "@context": [
    "https://doi.org/10.5063/schema/codemeta-2.0",
    "http://schema.org"
  ],
  "@type": "SoftwareSourceCode",
  "identifier": "Rclean",
  "description": "To create clearer, more concise code provides this\n\t     toolbox helps coders to isolate the essential parts of a\n\t     script that produces a chosen result, such as an object,\n\t     tables and figures written to disk.",
  "name": "Rclean: A Tool for Writing Cleaner, More Transparent Code",
  "codeRepository": "https://github.com/MKLau/Rclean",
  "issueTracker": "https://github.com/MKLau/Rclean/issues",
  "license": "https://spdx.org/licenses/GPL-3.0",
  "version": "1.1.7",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "version": "3.6.2",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 3.6.2 (2019-12-12)",
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "roxygen2",
      "name": "roxygen2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=roxygen2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "covr",
      "name": "covr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=covr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    }
  ],
  "softwareRequirements": [
    {
      "@type": "SoftwareApplication",
      "identifier": "R",
      "name": "R",
      "version": ">= 3.5.0"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "igraph",
      "name": "igraph",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=igraph"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "CodeDepends",
      "name": "CodeDepends",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://github.com/MKLau/CodeDepends"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "methods",
      "name": "methods"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "Rgraphviz",
      "name": "Rgraphviz",
      "provider": {
        "@id": "https://www.bioconductor.org",
        "@type": "Organization",
        "name": "BioConductor",
        "url": "https://www.bioconductor.org"
      },
      "sameAs": "https://bioconductor.org/packages/release/bioc/html/Rgraphviz.html"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "clipr",
      "name": "clipr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=clipr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "styler",
      "name": "styler",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=styler"
    }
  ],
  "releaseNotes": "https://github.com/mklau/rclean/blob/master/NEWS.md",
  "readme": "https://github.com/ropensci/Rclean/blob/master/README.md",
  "contIntegration": [
    "https://travis-ci.org/ROpenSci/Rclean",
    "https://codecov.io/github/ROpenSci/Rclean?branch=master"
  ],
  "developmentStatus": [
    "http://www.repostatus.org/#active",
    "https://www.tidyverse.org/lifecycle/#maturing"
  ],
  "author": [
    {
      "@type": "Person",
      "givenName": "Matthew",
      "familyName": "Lau",
      "email": "matthewklau@fas.harvard.edu",
      "@id": "https://orcid.org/0000-0003-3758-2406"
    }
  ],
  "contributor": {},
  "copyrightHolder": {},
  "funder": {},
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Matthew",
      "familyName": "Lau",
      "email": "matthewklau@fas.harvard.edu",
      "@id": "https://orcid.org/0000-0003-3758-2406"
    }
  ],
  "fileSize": "315.665KB"
}

GitHub Events

Total
Last Year

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 547
  • Total Committers: 4
  • Avg Commits per committer: 136.75
  • Development Distribution Score (DDS): 0.009
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
mklau m****u@f****u 542
Maëlle Salmon m****n@y****e 2
Daniel S. Katz d****z@i****g 2
glomus g****s@p****n 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 73
  • Total pull requests: 27
  • Average time to close issues: 6 months
  • Average time to close pull requests: 4 days
  • Total issue authors: 4
  • Total pull request authors: 4
  • Average comments per issue: 0.41
  • Average comments per pull request: 1.44
  • Merged pull requests: 24
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • MKLau (68)
  • maelle (3)
  • javimarlop (1)
  • njtierney (1)
Pull Request Authors
  • MKLau (23)
  • danielskatz (2)
  • maelle (1)
  • annakrystalli (1)
Top Labels
Issue Labels
ropensci (26) enhancement (14) priority (3) bug (1) question (1) help wanted (1) BLOCKED (1)
Pull Request Labels

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • CodeDepends * imports
  • Rgraphviz * imports
  • clipr * imports
  • igraph * imports
  • methods * imports
  • styler * imports
  • covr * suggests
  • knitr * suggests
  • roxygen2 * suggests
  • testthat * suggests