Learn R Programming

⚠️There's a newer version (0.1.6) of this package.Take me there.

pryr (rhymes with pry bar)

pryr provides tools to pry back the surface of R and dig into the details. It has been developed in conjunction with "Advanced R programming" to make it easier to understand what's going on in R.

Install it from CRAN with install.packages("pryr").

Tools

pryr includes tools to:

  • Make it easier to understand the internal implementation of:

    • promises: uneval(), is_promise(), promise_info()
    • scoping and environments: where(), rls(), parenv()
    • closures: unenclose()
    • calls and expressions: call_tree()
    • primitive types: typenames()
    • copy-on-modify: address(), track_copy()
  • Inspect and understand R's OO systems:

    • Determine which OO system an object belongs to: otype()
    • Determine which OO system a function belongs to: ftype()
  • Make it easier to compute on the language:

    • Alternative ways to create functions: make_function(), f()
    • A version of substitute that uses regular evaluation, substitute_q(), and one that will substitute objects in the global environment, subs()
    • Tools to modify language objects: modify_lang()
    • dots() and named_dots() to get unevaluated ...
    • Partial function evaluation: partial()
    • Find all functions matching some criteria: find_funs()
  • To use existing R tools more easily:

    • %<d-% and %<a-% for creating delayed or active bindings
    • %<c-% for creating constants (locked bindings)
    • rebind as a more user friendly version of <<-

Copy Link

Version

Install

install.packages('pryr')

Monthly Downloads

20,460

Version

0.1.3

License

GPL-2

Issues

Pull Requests

Stars

Forks

Maintainer

Hadley Wickham

Last Published

October 30th, 2017

Functions in pryr (0.1.3)

enclosing_env

Find the environment that encloses of a function.
explicit

Tools for making promises explicit
is_s3_generic

Determine if a function is an S3 generic or S3 method.
make_call

Make and evaluate calls.
modify_call

Modify the arguments of a call.
modify_lang

Recursively modify a language object
substitute_q

A version of substitute that evaluates its first argument.
subs

A version of substitute that works in the global environment.
%<c-%

Create a constant (locked) binding.
%<d-%

Create an delayed binding.
is_active_binding

Active binding info
is_promise

Promise info
otype

Determine object type.
parent_promise

Find the parent (first) promise.
parenv

Get parent/ancestor environment
parenvs

Given an environment or object, return an envlist of its parent environments.
track_copy

Track if an object is copied
unenclose

Unenclose a closure.
ftype

Determine function type.
sexp_type

Inspect internal attributes of R objects.
make_function

Make a function from its components.
mem_change

Determine change in memory from running code
bytes

Print the byte-wise representation of a value
call_tree

Display a call (or expression) as a tree.
as.envlist

Convert a list of environments to an envlist object.
%<a-%

Create an active binding.
names_c

Extract function table from names.c from R subversion repository.
object_size

Compute the size of an object.
show_c_source

Find C source code for internal R functions
standardise_call

Standardise a function call
uneval

Capture the call associated with a promise.
where

Find where a name is defined.
f

A compact syntax for anonymous functions.
fget

Find a function with specified name.
compose

Compose multiple functions
dots

Capture unevaluated dots.
mem_used

How much memory is currently used by R?
method_from_call

Given a function class, find correspoding S4 method
partial

Partial apply a function, filling in some arguments.
print.envlist

Print an envlist
rebind

Rebind an existing name.
rls

Recursive ls.
find_funs

Find functions matching criteria.
find_uses

Find all functions in that call supplied functions.