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,956,217

Version

0.2.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 16th, 2018

Functions in rlang (0.2.2)

dots_values

Evaluate dots with preliminary splicing
has_name

Does an object have an element with this name?
as_overscope

Create an overscope
as_pairlist

Coerce to pairlist
abort

Signal an error, warning, or message
as_quosure

Coerce object to quosure
are_na

Test for missing values
inherits_any

Does an object inherit from a set of classes?
is_frame

Is object a frame?
as_utf8_character

Coerce to a character vector and attempt encoding conversion
is_function

Is object a function?
is_quosureish

Test for or coerce to quosure-like objects
as_data_mask

Create a data mask
deprecated-cnd

Deprecated condition constructors
call_fn

Extract function from a call
is_reference

Is an object referencing another?
as_environment

Coerce to an environment
env_get

Get an object in an environment
f_rhs

Get or set formula components
eval_tidy

Evaluate an expression with quosures and pronoun support
eval_bare

Evaluate an expression in an environment
dictionary

Create a dictionary
env_depth

Depth of an environment chain
as_function

Convert to function or closure
call_inspect

Inspect a call
as_env

Coerce to an environment
call_standardise

Standardise a call
f_text

Turn RHS of formula into a string or label
invoke

Invoke a function with a list of arguments
is_call

Is object a call?
is_namespace

Is an object a namespace environment?
call2

Create a call
caller_env

Get the environment of the caller frame
empty_env

Get the empty environment
call_args

Extract arguments from a call
arg_match

Match an argument to a character vector
env

Create a new environment
is_pairlist

Is object a node or pairlist?
mut_node_car

Mutate node components
mut_utf8_locale

Set the locale's codeset for testing
names2

Get names of a vector
catch_cnd

Catch a condition
op-definition

Definition operator
env_poke

Poke an object in an environment
chr_unserialise_unicode

Translate unicode points to UTF-8
as_bytes

Coerce to a raw vector
env_bury

Mask bindings by defining symbols deeper in a scope
env_clone

Clone an environment
new-vector-along

Create vectors matching the length of a given vector
env_unbind

Remove bindings from an environment
new-vector

Create vectors matching a given length
op-get-attr

Infix attribute accessor
call_modify

Modify the arguments of a call
call_name

Extract function name of a call
dots_n

How many arguments are currently forwarded in dots?
dots_definitions

Capture definition objects
bare-type-predicates

Bare type predicates
env_bind

Bind symbols to objects in an environment
new_call

Create a new call from components
quo_squash

Squash a quosure
env_bind_exprs

Bind lazy or active bindings
env_has

Does an environment have or see bindings?
quosure

Quosure getters, setters and testers
env_names

Names of symbols bound in an environment
prim_name

Name of a primitive function
fn_env

Return the closure environment of a function
fn_fmls

Extract arguments from a function
string

Create a string
tidy-dots

Collect dots tidily
switch_lang

Dispatch on call type
tidyeval-data

Data pronoun for tidy evaluation
quasiquotation

Quasiquotation of an expression
env_parent

Get parent environments
box

Box a value
env_inherits

Does environment inherit from another environment?
is_expression

Is an object an expression?
cnd

Create a condition object
with_restarts

Establish a restart point on the stack
is_formula

Is object a formula?
lang_head

Return the head or tail of a call
scoped_env

Scoped environments
lang_modify

Manipulate or access a call
scoped_options

Change global options
quotation

Quotation
expr_interp

Process unquote operators in a captured expression
cnd_signal

Signal a condition
eval_tidy_

Tidy evaluation in a custom environment
frame_position

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

Turn an expression to a label
is_callable

Is an object callable?
is_condition

Is object a condition?
friendly_type

Format a type for error messages
is_installed

Is a package installed in the library?
restarting

Create a restarting handler
is_copyable

Is an object copyable?
set_attrs

Add attributes to an object
seq2

Increasing sequence of integers in an interval
exiting

Create an exiting or in place handler
set_names

Set names of a vector
expr_print

Print an expression
exprs_auto_name

Ensure that list of expressions are all named
splice

Splice lists
is_empty

Is object an empty vector or NULL?
vec_poke_n

Poke values into a vector
vector-coercion

Coerce an object to a base type
has_length

How long is an object?
get_env

Get or set the environment of an object
is_integerish

Is a vector integer-like?
is_true

Is object identical to TRUE or FALSE?
is_env

Is object an environment?
is_expr

Is an object an expression?
lang

Create a call
new_node

Helpers for pairlist and language nodes
is_stack

Is object a stack?
is_lang

Is object a call?
is_symbol

Is object a symbol?
lifecycle

Life cycle of the rlang package
new_formula

Create a formula
missing

Missing values
new_function

Create a function
parse_quosure

Parse text into a quosure
ns_env

Get the namespace of a package
quo_expr

Squash a quosure
prepend

Prepend a vector
rst_list

Restarts utilities
rst_muffle

Jump to a muffling restart
stack

Call stack information
quo_label

Format quosures for printing or labelling
stack_trim

Trim top call layers from the evaluation stack
return_from

Jump to or from a frame
vector-construction

Create vectors
is_named

Is object named?
vector-old-ctors

Retired vector construction by length
rst_abort

Jump to the abort restart
missing_arg

Generate or handle a missing argument
modify

Modify a vector
set_chr_encoding

Set encoding of a string or character vector
set_expr

Set and get an expression
type-predicates

Type predicates
type_of

Base type of an object
with_env

Evaluate an expression within a given environment
op-na-default

Replace missing values
with_handlers

Establish handlers on the stack
op-null-default

Default value for NULL
overscope_eval_next

Evaluate next quosure in a data mask
parse_quosures

Parse R code
scalar-type-predicates

Scalar type predicates
scoped_bindings

Temporarily change bindings of an environment
sym

Create a symbol or list of symbols
switch_type

Dispatch on base types
duplicate

Duplicate an R object
flatten

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

Get or set function body