The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Type: Package
Title: Analyze Lines of R Code the Tidy Way
Version: 0.1.1
Description: Analyze lines of R code using tidy principles. This allows you to input lines of R code and output a data frame with one row per function included. Additionally, it facilitates code classification via included lexicons.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Imports: purrr, pryr, tibble, rlang, glue, matahari
URL: https://github.com/LucyMcGowan/tidycode
BugReports: https://github.com/LucyMcGowan/tidycode/issues
Suggests: testthat, covr, knitr, rmarkdown, dplyr
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2019-12-10 15:35:41 UTC; lucymcgowan
Author: Lucy D'Agostino McGowan ORCID iD [aut, cre], Jim Hester [ctb], Jeff Leek [ldr]
Maintainer: Lucy D'Agostino McGowan <lucydagostino@gmail.com>
Repository: CRAN
Date/Publication: 2019-12-10 19:30:02 UTC

Pipe operator

Description

Pipe operator

Usage

lhs %>% rhs

Get a tidy data frame of classifications of all functions used in your analysis

Description

Get a tidy data frame of classifications of all functions used in your analysis

Usage

get_classifications(lexicon = NULL, include_duplicates = TRUE)

Arguments

lexicon

Character. The classification lexicon to retrieve. Either "crowdsource" or "leeklab". If NULL (default), will return all lexicons.

include_duplicates

Logical. Indicates whether to include all functions and classifications along with their score (default, TRUE) - this may result in multiple lines (with multiple classifications) for a single function. If FALSE, the most prevalent classification will be selected.

Value

A tbl_df with columns:

If include_duplicates = TRUE, will include a column:

If lexicon is NULL, will include a column:

Examples

# Get a data frame of all classifications
get_classifications()

# Get a data frame of the most prevalent classifications
get_classifications(include_duplicates = FALSE)

# Get a data frame of only `leeklab` classifications
get_classifications("leeklab")


Get a tidy data frame of a "stopword" lexicon for R functions

Description

Get a data frame listing one function per row.

Usage

get_stopfuncs()

Value

A tbl_df with one column:

Examples

get_stopfuncs()

List packages

Description

List packages

Usage

ls_packages(x)

Arguments

x

an R call or list of R calls

Value

Character. Vector of packages called.

Examples

ls_packages(
  list(
    quote(library(tidycode)),
    quote(library(purrr)))
  )

Read R file(s) as a tidy data frame

Description

Read R file(s) as a tidy data frame

Usage

read_rfiles(...)

Arguments

...

One or more quoted R file paths to read

Value

A tidy data frame, a tbl_df, with one row per R call. There will be three columns,

Examples

d <- read_rfiles(
  tidycode_example("example_plot.R"),
  tidycode_example("example_analysis.R")
)

Get path to example file

Description

tidycode comes bundled with a few small files to use in examples. This function makes them easy to access.

Usage

tidycode_example(path = NULL)

Arguments

path

Name of file. If NULL, the example files will be listed.

Examples

tidycode_example()
tidycode_example("example_plot.R")

Unnest R calls

Description

Unnest R calls

Usage

unnest_calls(.data, input, drop = TRUE)

Arguments

.data

A data frame

input

Input column that contains an R call or list of R calls to be split into individual functions

drop

logical. Whether the original input column should be dropped.

Value

The original data frame with an additional three columns:

Examples

d <- read_rfiles(tidycode_example("example_plot.R"))

# Unnest a model call
d %>%
  unnest_calls(expr)

# Unnest a model call and keep the call itself using the drop parameter
d %>%
  unnest_calls(expr, drop = FALSE)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.