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

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

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:

```{R install_rgraphviz, eval = FALSE}

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

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

```r
library(Rclean)

Usage

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

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)

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

get_vars(script)

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

We can also select several variables at the same time:

my.vars <- c("tab.12", "tab.15")
clean(script, my.vars)

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



MKLau/Rclean documentation built on Dec. 6, 2022, 7:18 p.m.