Learn R Programming

⚠️There's a newer version (1.1.4) 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,442,500

Version

0.1.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Lionel Henry

Last Published

June 4th, 2024

Functions in rlang (0.1.1)

as_env

Coerce to an environment
as_function

Convert to function or closure
abort

Signal an error, warning, or message
are_na

Test for missing values
as_quosure

Coerce object to quosure
as_utf8_character

Coerce to a character vector and attempt encoding conversion
as_overscope

Create a dynamic scope for tidy evaluation
as_pairlist

Coerce to pairlist
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
dots_n

How many arguments are currently forwarded in dots?
dots_values

Evaluate dots with preliminary splicing
env_has

Does an environment have or see bindings?
duplicate

Duplicate an R object
empty_env

Get the empty environment
env_bury

Overscope bindings by defining symbols deeper in a scope
env_clone

Clone an environment
env_names

Names of symbols bound in an environment
exiting

Create an exiting or in place handler
expr

Raw quotation of an expression
f_text

Turn RHS of formula into a string or label
flatten

Flatten or squash a list of lists into a simpler vector
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
fn_env

Return the closure environment of a function
fn_fmls

Extract arguments from a function
env_parent

Get parent environments
expr_interp

Process unquote operators in a captured expression
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
is_env

Is object an environment?
is_expr

Is an object an expression?
is_integerish

Is a vector integer-like?
is_formula

Is object a formula?
is_frame

Is object a frame?
lang

Create a call
lang_args

Extract arguments from a call
is_copyable

Is an object copyable?
is_empty

Is object an empty vector or NULL?
is_named

Is object named?
is_pairlist

Is object a node or pairlist?
env_inherits

Does environment inherit from another environment?
env_unbind

Remove bindings from an environment
eval_bare

Evaluate an expression in an environment
has_name

Does an object have an element with this name?
dictionary

Create a dictionary
dots_list

Extract dots with splicing semantics
env

Create a new environment
env_bind

Bind symbols to objects in an environment
eval_tidy

Evaluate an expression tidily
eval_tidy_

Tidy evaluation in a custom environment
get_env

Get or set the environment of an object
has_length

How long is an object?
is_function

Is object a function?
lang_standardise

Standardise a call
missing

Missing values
new_cnd

Create a condition object
new_formula

Create a formula
is_lang

Is object a call?
missing_arg

Generate or handle a missing argument
modify

Modify a vector
op-na-default

Replace missing values
prepend

Prepend a vector
prim_name

Name of a primitive function
rst_list

Restarts utilities
op-null-default

Default value for NULL
return_from

Jump to or from a frame
rst_abort

Jump to the abort restart
scalar-type-predicates

Scalar type predicates
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
invoke

Invoke a function with a list of arguments
is_callable

Is an object callable?
is_condition

Is object a condition?
rst_muffle

Jump to a muffling restart
string

Create a string
switch_lang

Dispatch on call type
scoped_env

Scoped environments
stack

Call stack information
stack_trim

Trim top call layers from the evaluation stack
is_quosure

Is an object a quosure or quosure-like?
is_stack

Is object a stack?
lang_fn

Extract function from a call
lang_head

Return the head or tail of a call object
quo_expr

Splice a quosure and format it into string or label
quosure

Create quosures
seq2

Increasing sequence of integers in an interval
op-definition

Definition operator
op-get-attr

Infix attribute accessor
dots_definitions

Tidy quotation of multiple expressions and dots
restarting

Create a restarting handler
is_installed

Is a package installed in the library?
is_symbol

Is object a symbol?
is_true

Is object identical to TRUE or FALSE?
lang_modify

Modify the arguments of a call
set_names

Set names of a vector
splice

Splice a list within a vector
tidyeval-data

Data pronoun for tidy evaluation
set_attrs

Add attributes to an object
switch_type

Dispatch on base types
sym

Create a symbol or list of symbols
type-predicates

Type predicates
vector-len

Create vectors matching a given length
with_handlers

Establish handlers on the stack
with_restarts

Establish a restart point on the stack
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
quo-predicates

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

Set encoding of a string or character vector
with_env

Evaluate an expression within a given environment
set_expr

Set and get an expression
type_of

Base type of an object
vector-along

Create vectors matching the length of a given vector
vector-coercion

Coerce an object to a base type
vector-construction

Create vectors