Learn R Programming

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

rlang

Important: The rlang API is still maturing. Please see ?rlang::lifecycle for the list of functions that are considered stable.

Overview

The rlang package provides tools to work with core language features of R and the tidyverse:

  • The tidy eval framework, which is a well-founded system for non-standard evaluation built on quasiquotation (!!) and quosures (quo()).

  • Consistent tools for working with base types. Note that overall this is a work in progress that is still in flux:

    • Vectors, including construction (lgl(), int(), ...) coercion (as_logical(), as_character(), ...), and predicates (is_logical(), is_character()).

    • Language objects, such as calls (lang()) and symbols (sym()).

    • Attributes, e.g. set_names().

    • Functions, e.g. new_function(), as_function(). The latter supports the purrr-style formula notation for lambda functions.

    • Environments, e.g. env(), env_has(), env_get(), env_bind(), env_unbind().

  • A comprehensive set of predicates to determine if an object satisfies various conditions, e.g. has_length(), is_list(), is_empty().

  • The condition (message, warning, error) and restart system.

Installation

You can install the released version of rlang from CRAN with:

install.packages("rlang")

Or install the development version from github with:

# install.packages("devtools")
devtools::install_github("r-lib/rlang", build_vignettes = TRUE)

Copy Link

Version

Install

install.packages('rlang')

Monthly Downloads

1,820,374

Version

0.2.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

May 30th, 2018

Functions in rlang (0.2.1)

call_args

Extract arguments from a call
catch_cnd

Catch a condition
env_depth

Depth of an environment chain
deprecated-cnd

Deprecated condition constructors
dots_n

How many arguments are currently forwarded in dots?
cnd_signal

Signal a condition
env_bind

Bind symbols to objects in an environment
env_names

Names of symbols bound in an environment
dots_definitions

Capture definition objects
env_bind_exprs

Bind lazy or active bindings
chr_unserialise_unicode

Translate unicode points to UTF-8
call_standardise

Standardise a call
dictionary

Create a dictionary
cnd

Create a condition object
expr_print

Print an expression
eval_bare

Evaluate an expression in an environment
eval_tidy

Evaluate an expression with quosures and pronoun support
call_inspect

Inspect a call
exprs_auto_name

Ensure that list of expressions are all named
env_parent

Get parent environments
env_get

Get an object in an environment
f_text

Turn RHS of formula into a string or label
dots_values

Evaluate dots with preliminary splicing
f_rhs

Get or set formula components
get_env

Get or set the environment of an object
flatten

Flatten or squash a list of lists into a simpler vector
has_length

How long is an object?
is_callable

Is an object callable?
fn_body

Get or set function body
is_quosureish

Test for or coerce to quosure-like objects
caller_env

Get the environment of the caller frame
empty_env

Get the empty environment
is_condition

Is object a condition?
duplicate

Duplicate an R object
is_reference

Is an object referencing another?
env_unbind

Remove bindings from an environment
env_poke

Poke an object in an environment
is_frame

Is object a frame?
frame_position

Find the position or distance of a frame on the evaluation stack
fn_env

Return the closure environment of a function
env

Create a new environment
lifecycle

Life cycle of the rlang package
missing

Missing values
eval_tidy_

Tidy evaluation in a custom environment
env_bury

Mask bindings by defining symbols deeper in a scope
fn_fmls

Extract arguments from a function
env_clone

Clone an environment
exiting

Create an exiting or in place handler
new_node

Helpers for pairlist and language nodes
has_name

Does an object have an element with this name?
ns_env

Get the namespace of a package
is_env

Is object an environment?
inherits_any

Does an object inherit from a set of classes?
env_has

Does an environment have or see bindings?
friendly_type

Format a type for error messages
is_copyable

Is an object copyable?
parse_quosure

Parse text into a quosure
prepend

Prepend a vector
set_expr

Set and get an expression
set_chr_encoding

Set encoding of a string or character vector
scoped_options

Change global options
is_expr

Is an object an expression?
tidy-dots

Collect dots tidily
is_function

Is object a function?
tidyeval-data

Data pronoun for tidy evaluation
scoped_env

Scoped environments
is_stack

Is object a stack?
is_installed

Is a package installed in the library?
is_true

Is object identical to TRUE or FALSE?
env_inherits

Does environment inherit from another environment?
expr_interp

Process unquote operators in a captured expression
names2

Get names of a vector
is_symbol

Is object a symbol?
new-vector-along

Create vectors matching the length of a given vector
is_integerish

Is a vector integer-like?
new_formula

Create a formula
is_empty

Is object an empty vector or NULL?
new_function

Create a function
is_lang

Is object a call?
op-get-attr

Infix attribute accessor
op-definition

Definition operator
is_named

Is object named?
quo_expr

Squash a quosure
quo_squash

Squash a quosure
quosure

Quosure getters, setters and testers
modify

Modify a vector
missing_arg

Generate or handle a missing argument
rst_list

Restarts utilities
op-na-default

Replace missing values
expr_label

Turn an expression to a label
invoke

Invoke a function with a list of arguments
quo_label

Format quosures for printing or labelling
op-null-default

Default value for NULL
is_call

Is object a call?
is_expression

Is an object an expression?
stack

Call stack information
scalar-type-predicates

Scalar type predicates
type-predicates

Type predicates
stack_trim

Trim top call layers from the evaluation stack
rst_muffle

Jump to a muffling restart
lang

Create a call
is_formula

Is object a formula?
is_namespace

Is an object a namespace environment?
prim_name

Name of a primitive function
scoped_bindings

Temporarily change bindings of an environment
is_pairlist

Is object a node or pairlist?
mut_node_car

Mutate node components
string

Create a string
switch_lang

Dispatch on call type
with_env

Evaluate an expression within a given environment
type_of

Base type of an object
mut_utf8_locale

Set the locale's codeset for testing
lang_head

Return the head or tail of a call
new-vector

Create vectors matching a given length
lang_modify

Manipulate or access a call
quasiquotation

Quasiquotation of an expression
with_handlers

Establish handlers on the stack
overscope_eval_next

Evaluate next quosure in a data mask
new_call

Create a new call from components
switch_type

Dispatch on base types
sym

Create a symbol or list of symbols
quotation

Quotation
parse_quosures

Parse R code
return_from

Jump to or from a frame
restarting

Create a restarting handler
set_names

Set names of a vector
splice

Splice lists
seq2

Increasing sequence of integers in an interval
rst_abort

Jump to the abort restart
set_attrs

Add attributes to an object
vector-construction

Create vectors
vector-old-ctors

Retired vector construction by length
vec_poke_n

Poke values into a vector
with_restarts

Establish a restart point on the stack
vector-coercion

Coerce an object to a base type
abort

Signal an error, warning, or message
as_data_mask

Create a data mask
as_environment

Coerce to an environment
are_na

Test for missing values
as_function

Convert to function or closure
arg_match

Match an argument to a character vector
as_env

Coerce to an environment
bare-type-predicates

Bare type predicates
call_fn

Extract function from a call
call_modify

Modify the arguments of a call
as_overscope

Create an overscope
call2

Create a call
as_utf8_character

Coerce to a character vector and attempt encoding conversion
as_bytes

Coerce to a raw vector
box

Box a value
as_quosure

Coerce object to quosure
as_pairlist

Coerce to pairlist
call_name

Extract function name of a call