Learn R Programming

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

rlang

Overview

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

  • The tidyeval framework, which is a well-founded system for non-standard evaluation built on quasiquotation (UQ()) and quosures (quo()). Read more in vignette("tidy-evaluation").

  • Consistent tools for working with base types:

    • 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_attrs(), set_names().

    • Functions, e.g. new_function(), as_function(), is_function().

    • 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.

  • Call and context stacks.

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("tidyverse/rlang", build_vignettes = TRUE)

Copy Link

Version

Install

install.packages('rlang')

Monthly Downloads

1,917,895

Version

0.1.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Lionel Henry

Last Published

April 11th, 2025

Functions in rlang (0.1.2)

as_env

Coerce to an environment
as_function

Convert to function or closure
as_overscope

Create a dynamic scope for tidy evaluation
as_pairlist

Coerce to pairlist
as_quosure

Coerce object to quosure
as_utf8_character

Coerce to a character vector and attempt encoding conversion
abort

Signal an error, warning, or message
are_na

Test for missing values
arg_match

Match an argument to a character vector
as_bytes

Coerce to a raw vector
caller_env

Get the environment of the caller frame
cnd_signal

Signal a condition
env_names

Names of symbols bound in an environment
env_parent

Get parent environments
duplicate

Duplicate an R object
empty_env

Get the empty environment
env

Create a new environment
bare-type-predicates

Bare type predicates
call_inspect

Inspect a call
env_depth

Depth of an environment chain
env_get

Get an object from an environment
exprs_auto_name

Ensure that list of expressions are all named
f_rhs

Get or set formula components
has_name

Does an object have an element with this name?
invoke

Invoke a function with a list of arguments
is_formula

Is object a formula?
is_frame

Is object a frame?
is_integerish

Is a vector integer-like?
is_lang

Is object a call?
dots_n

How many arguments are currently forwarded in dots?
dots_values

Evaluate dots with preliminary splicing
env_bury

Overscope bindings by defining symbols deeper in a scope
env_clone

Clone an environment
expr_interp

Process unquote operators in a captured expression
eval_tidy

Evaluate an expression tidily
eval_tidy_

Tidy evaluation in a custom environment
f_text

Turn RHS of formula into a string or label
flatten

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

Extract function from a call
lang_head

Return the head or tail of a call object
op-na-default

Replace missing values
op-null-default

Default value for NULL
prepend

Prepend a vector
prim_name

Name of a primitive function
set_chr_encoding

Set encoding of a string or character vector
env_bind

Bind symbols to objects in an environment
env_unbind

Remove bindings from an environment
eval_bare

Evaluate an expression in an environment
fn_env

Return the closure environment of a function
fn_fmls

Extract arguments from a function
is_copyable

Is an object copyable?
is_empty

Is object an empty vector or NULL?
dictionary

Create a dictionary
dots_list

Extract dots with splicing semantics
env_has

Does an environment have or see bindings?
env_inherits

Does environment inherit from another environment?
expr_label

Turn an expression to a label
frame_position

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

Format a type for error messages
lang

Create a call
lang_args

Extract arguments from a call
missing_arg

Generate or handle a missing argument
exiting

Create an exiting or in place handler
expr

Raw quotation of an expression
get_env

Get or set the environment of an object
has_length

How long is an object?
modify

Modify a vector
new_cnd

Create a condition object
new_formula

Create a formula
dots_definitions

Tidy quotation of multiple expressions and dots
restarting

Create a restarting handler
is_callable

Is an object callable?
is_condition

Is object a condition?
is_symbol

Is object a symbol?
is_true

Is object identical to TRUE or FALSE?
is_env

Is object an environment?
is_expr

Is an object an expression?
is_named

Is object named?
is_pairlist

Is object a node or pairlist?
lang_modify

Modify the arguments of a call
lang_name

Extract function name of a call
new_function

Create a function
ns_env

Get the namespace of a package
quasiquotation

Quasiquotation of an expression
is_function

Is object a function?
is_installed

Is a package installed in the library?
is_quosure

Is an object a quosure or quosure-like?
rst_list

Restarts utilities
rst_muffle

Jump to a muffling restart
switch_type

Dispatch on base types
set_expr

Set and get an expression
stack

Call stack information
stack_trim

Trim top call layers from the evaluation stack
vector-coercion

Coerce an object to a base type
quo-predicates

Is a quosure quoting a symbolic, missing or NULL object?
sym

Create a symbol or list of symbols
vector-len

Create vectors matching a given length
with_env

Evaluate an expression within a given environment
is_stack

Is object a stack?
lang_standardise

Standardise a call
missing

Missing values
op-definition

Definition operator
vector-construction

Create vectors
set_names

Set names of a vector
splice

Splice a list within a vector
tidyeval-data

Data pronoun for tidy evaluation
type-predicates

Type predicates
with_handlers

Establish handlers on the stack
with_restarts

Establish a restart point on the stack
mut_utf8_locale

Set the locale's codeset for testing
names2

Get names of a vector
pairlist

Helpers for pairlist and language nodes
parse_expr

Parse R code
quo_expr

Splice a quosure and format it into string or label
quosure

Create quosures
scalar-type-predicates

Scalar type predicates
scoped_env

Scoped environments
string

Create a string
switch_lang

Dispatch on call type
op-get-attr

Infix attribute accessor
return_from

Jump to or from a frame
rst_abort

Jump to the abort restart
seq2

Increasing sequence of integers in an interval
set_attrs

Add attributes to an object
type_of

Base type of an object
vector-along

Create vectors matching the length of a given vector