{"id":14069913,"url":"https://github.com/ropensci-archive/Rclean","last_synced_at":"2025-07-30T06:33:25.841Z","repository":{"id":44886208,"uuid":"102645585","full_name":"ropensci-archive/Rclean","owner":"ropensci-archive","description":":warning: ARCHIVED :warning: Isolate essential code to re-produce specific results.","archived":true,"fork":false,"pushed_at":"2022-12-06T12:36:38.000Z","size":9625,"stargazers_count":96,"open_issues_count":0,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-08-13T07:16:28.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ropensci-archive.png","metadata":{"files":{"readme":"README-not.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-06T18:45:59.000Z","updated_at":"2024-01-06T17:41:27.000Z","dependencies_parsed_at":"2023-01-24T01:45:06.851Z","dependency_job_id":null,"html_url":"https://github.com/ropensci-archive/Rclean","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci-archive%2FRclean","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci-archive%2FRclean/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci-archive%2FRclean/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ropensci-archive%2FRclean/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ropensci-archive","download_url":"https://codeload.github.com/ropensci-archive/Rclean/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228102411,"owners_count":17869845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:07:19.874Z","updated_at":"2024-12-04T11:31:06.578Z","avatar_url":"https://github.com/ropensci-archive.png","language":"TeX","funding_links":[],"categories":["TeX"],"sub_categories":[],"readme":"\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\u003c!-- # ijtiff  \u003cimg src=\"man/figures/logo.png\" height=\"140\" align=\"right\"\u003e --\u003e\n\u003c!-- Code status --\u003e\n[![Build\nStatus](https://travis-ci.org/ROpenSci/Rclean.svg?branch=master)](https://travis-ci.org/ROpenSci/Rclean)\n[![Coverage\nstatus](https://codecov.io/gh/ROpenSci/Rclean/branch/master/graph/badge.svg)](https://codecov.io/github/ROpenSci/Rclean?branch=master)\n\n\u003c!-- R status --\u003e\n[![CRAN\\_Status\\_Badge](http://www.r-pkg.org/badges/version/Rclean)](https://cran.r-project.org/package=Rclean)\n![RStudio CRAN\ndownloads](http://cranlogs.r-pkg.org/badges/grand-total/Rclean)\n![RStudio CRAN monthly\ndownloads](http://cranlogs.r-pkg.org/badges/Rclean)\n[![Rdocumentation](http://www.rdocumentation.org/badges/version/Rclean)](http://www.rdocumentation.org/packages/Rclean)\n\n\u003c!-- Dev status --\u003e\n[![Project Status: Active – The project has reached a stable, usable\nstate and is being actively\ndeveloped.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)\n[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)\n\n\u003c!-- Package Review --\u003e\n[![](https://badges.ropensci.org/327_status.svg)](https://github.com/ropensci/software-review/issues/327)\n[![status](http://joss.theoj.org/papers/334d80d5508056dc6e7e17c6fd3ed5a6/status.svg)](http://joss.theoj.org/papers/334d80d5508056dc6e7e17c6fd3ed5a6)\n\n\u003c!-- Archiving --\u003e\n[![DOI](https://zenodo.org/badge/102645585.svg)](https://zenodo.org/badge/latestdoi/102645585)\n\nQuick Start Guide\n=================\n\n-   [Rclean](https://github.com/MKLau/Rclean) was created to help\n    scientists more *easily* write “cleaner” code.\n-   Written with research scientists that are results oriented in mind,\n    the package’s primary function provides a simple way to isolate the\n    minimal code you need to produce a specific result, such as a\n    statistical table or a figure. By focusing on specific results (aka.\n    variables), large and/or complicated analytical scripts can be\n    paired down to the essentials and easily re-factored to be more\n    robust and easily shared.\n-   Below, you'll find a brief introduction to get you started using\n    the package. For more details, see `vignette(\"Rclean\")`.\n\nInstall\n=======\n\nYou can install the most up to date version easily with\n[devtools](https://github.com/hadley/devtools):\n\n    install.packages(\"devtools\")\n    devtools::install_github(\"MKLau/Rclean\")\n\nYou will also likely need to install the\n[RGraphViz](bioconductor.org/packages/release/bioc/html/Rgraphviz.html):\n\n\n    install.packages(\"BiocManager\")\n    BiocManager::install(\"Rgraphviz\")\n\nOnce installed, per usual R practice just load the *Rclean* package\nwith:\n\n    library(Rclean)\n\nUsage\n=====\n\n*Rclean* usage is simple. Have a script with code you want to clean\nsaved to disk. Then, just run the `clean` function with the path to the\nscript as the input. Here, we can use an example script that is included\nwith the package:\n\n    script \u003c- system.file(\"example\", \"simple_script.R\", package = \"Rclean\")\n\nHere's a quick look at the code:\n\n    readLines(script)\n    #\u003e  [1] \"## Make a data frame\"                             \n    #\u003e  [2] \"mat \u003c- matrix(rnorm(400), nrow = 100)\"            \n    #\u003e  [3] \"dat \u003c- as.data.frame(mat)\"                        \n    #\u003e  [4] \"dat[, \\\"V2\\\"] \u003c- dat[, \\\"V2\\\"] + runif(nrow(dat))\"\n    #\u003e  [5] \"dat[, \\\"V5\\\"] \u003c- gl(10, 10)\"                      \n    #\u003e  [6] \"## Conduct some analyses\"                         \n    #\u003e  [7] \"fit12 \u003c- lm(V1 ~ V2, data = dat)\"                 \n    #\u003e  [8] \"fit13 \u003c- lm(V1 ~ V3, data = dat)\"                 \n    #\u003e  [9] \"fit14 \u003c- lm(V1 ~ V4, data = dat)\"                 \n    #\u003e [10] \"fit15.aov \u003c- aov(V1 ~ V2 + V5, data = dat)\"       \n    #\u003e [11] \"## Summarize analyses\"                            \n    #\u003e [12] \"summary(fit15.aov)\"                               \n    #\u003e [13] \"tab.12 \u003c- summary(fit12)\"                         \n    #\u003e [14] \"tab.13 \u003c- summary(fit13)\"                         \n    #\u003e [15] \"tab.14 \u003c- summary(fit14)\"                         \n    #\u003e [16] \"tab.15 \u003c- append(fit15.aov, tab.14)\"              \n    #\u003e [17] \"## Conduct a calculation\"                         \n    #\u003e [18] \"dat \u003c- 25 + 2\"                                    \n    #\u003e [19] \"dat[2] \u003c- 10\"                                     \n    #\u003e [20] \"out \u003c- dat * 2\"\n\nYou can get a list of the variables found in an object with `get_vars`.\n\n    get_vars(script)\n    #\u003e  [1] \"mat\"       \"dat\"       \"fit12\"     \"fit13\"     \"fit14\"     \"fit15.aov\"\n    #\u003e  [7] \"tab.12\"    \"tab.13\"    \"tab.14\"    \"tab.15\"    \"out\"\n\nSometimes for more complicated scripts, it can be helpful to see a\nnetwork graph showing the interdependencies of variables. `code_graph`\nwill produce a network diagram showing which lines of code produce or\nuse which variables:\n\n\n    code_graph(script)\n\n\u003cimg src=\"man/figures/README-unnamed-chunk-7-1.png\" width=\"75%\" /\u003e\n\nNow, we can pick the result we want to focus on for cleaning:\n\n\n    clean(script, \"tab.15\")\n    #\u003e mat \u003c- matrix(rnorm(400), nrow = 100)\n    #\u003e dat \u003c- as.data.frame(mat)\n    #\u003e dat[, \"V2\"] \u003c- dat[, \"V2\"] + runif(nrow(dat))\n    #\u003e dat[, \"V5\"] \u003c- gl(10, 10)\n    #\u003e fit14 \u003c- lm(V1 ~ V4, data = dat)\n    #\u003e fit15.aov \u003c- aov(V1 ~ V2 + V5, data = dat)\n    #\u003e tab.14 \u003c- summary(fit14)\n    #\u003e tab.15 \u003c- append(fit15.aov, tab.14)\n    #\u003e dat \u003c- 25 + 2\n    #\u003e dat[2] \u003c- 10\n\nWe can also select several variables at the same time:\n\n    my.vars \u003c- c(\"tab.12\", \"tab.15\")\n    clean(script, my.vars)\n    #\u003e mat \u003c- matrix(rnorm(400), nrow = 100)\n    #\u003e dat \u003c- as.data.frame(mat)\n    #\u003e dat[, \"V2\"] \u003c- dat[, \"V2\"] + runif(nrow(dat))\n    #\u003e dat[, \"V5\"] \u003c- gl(10, 10)\n    #\u003e fit12 \u003c- lm(V1 ~ V2, data = dat)\n    #\u003e fit14 \u003c- lm(V1 ~ V4, data = dat)\n    #\u003e fit15.aov \u003c- aov(V1 ~ V2 + V5, data = dat)\n    #\u003e tab.12 \u003c- summary(fit12)\n    #\u003e tab.14 \u003c- summary(fit14)\n    #\u003e tab.15 \u003c- append(fit15.aov, tab.14)\n    #\u003e dat \u003c- 25 + 2\n    #\u003e dat[2] \u003c- 10\n\nWhile just taking a look at the simplified code can be very helpful, you\ncan also save the code for later use or sharing (e.g. creating a\nreproducible example for getting help) with `keep`:\n\n    my.code \u003c- clean(script, my.vars)\n    keep(my.code, file = \"results_tables.R\")\n\nIf you would like to copy your code to your clipboard, you can do that\nby not specifying a file path. You can now paste the simplified as\nneeded.\n\n    keep(my.code)\n\nContributing\n============\n\nThis is an open-source project. If you would like to contribute to the\nproject, please check out [CONTRIBUTING.md](CONTRIBUTING.md).\n\nPlease note that the 'Rclean' project is released with a [Contributor\nCode of Conduct](CODE_OF_CONDUCT.md). By contributing to this project,\nyou agree to abide by its terms.\n\n![ropensci\\_footer](https://ropensci.org/public_images/ropensci_footer.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci-archive%2FRclean","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fropensci-archive%2FRclean","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fropensci-archive%2FRclean/lists"}