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,820,374

Version

0.1.6

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

December 21st, 2017

Functions in rlang (0.1.6)

arg_match

Match an argument to a character vector
as_bytes

Coerce to a raw vector
abort

Signal an error, warning, or message
as_overscope

Create a dynamic scope for tidy evaluation
as_pairlist

Coerce to pairlist
as_function

Convert to function or closure
dictionary

Create a dictionary
bare-type-predicates

Bare type predicates
dots_n

How many arguments are currently forwarded in dots?
duplicate

Duplicate an R object
caller_env

Get the environment of the caller frame
empty_env

Get the empty environment
env_has

Does an environment have or see bindings?
env_inherits

Does environment inherit from another 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
dots_values

Evaluate dots with preliminary splicing
env_unbind

Remove bindings from an environment
eval_bare

Evaluate an expression in an environment
is_function

Is object a function?
is_installed

Is a package installed in the library?
is_true

Is object identical to TRUE or FALSE?
lang

Create a call
modify

Modify a vector
has_length

How long is an object?
is_copyable

Is an object copyable?
is_empty

Is object an empty vector or NULL?
lang_head

Return the head or tail of a call object
env

Create a new environment
env_bind

Bind symbols to objects in an environment
expr_interp

Process unquote operators in a captured expression
expr_label

Turn an expression to a label
mut_utf8_locale

Set the locale's codeset for testing
op-null-default

Default value for NULL
pairlist

Helpers for pairlist and language nodes
quo-predicates

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

Inspect a call
env_names

Names of symbols bound in an environment
env_parent

Get parent environments
exprs_auto_name

Ensure that list of expressions are all named
exiting

Create an exiting or in place handler
expr

Raw quotation of an expression
has_name

Does an object have an element with this name?
env_depth

Depth of an environment chain
env_get

Get an object from an environment
f_text

Turn RHS of formula into a string or label
flatten

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

Invoke a function with a list of arguments
is_callable

Is an object callable?
is_condition

Is object a condition?
is_stack

Is object a stack?
lang_modify

Modify the arguments of a call
new_formula

Create a formula
new_function

Create a function
is_formula

Is object a formula?
is_frame

Is object a frame?
is_named

Is object named?
is_pairlist

Is object a node or pairlist?
f_rhs

Get or set formula components
fn_env

Return the closure environment of a function
fn_fmls

Extract arguments from a function
is_quosure

Is an object a quosure or quosure-like?
missing

Missing values
missing_arg

Generate or handle a missing argument
op-get-attr

Infix attribute accessor
op-na-default

Replace missing values
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_symbol

Is object a symbol?
names2

Get names of a vector
new_cnd

Create a condition object
restarting

Create a restarting handler
parse_expr

Parse R code
prepend

Prepend a vector
set_attrs

Add attributes to an object
set_chr_encoding

Set encoding of a string or character vector
splice

Splice a list within a vector
quo_expr

Splice a quosure and format it into string or label
rst_abort

Jump to the abort restart
rst_list

Restarts utilities
stack_trim

Trim top call layers from the evaluation stack
is_expr

Is an object an expression?
is_integerish

Is a vector integer-like?
is_lang

Is object a call?
lang_name

Extract function name of a call
set_expr

Set and get an expression
set_names

Set names of a vector
sym

Create a symbol or list of symbols
tidyeval-data

Data pronoun for tidy evaluation
return_from

Jump to or from a frame
scoped_env

Scoped environments
seq2

Increasing sequence of integers in an interval
switch_lang

Dispatch on call type
stack

Call stack information
string

Create a string
with_env

Evaluate an expression within a given environment
with_handlers

Establish handlers on the stack
switch_type

Dispatch on base types
vector-coercion

Coerce an object to a base type
lang_standardise

Standardise a call
ns_env

Get the namespace of a package
op-definition

Definition operator
prim_name

Name of a primitive function
quasiquotation

Quasiquotation of an expression
rst_muffle

Jump to a muffling restart
vector-along

Create vectors matching the length of a given vector
scalar-type-predicates

Scalar type predicates
type-predicates

Type predicates
type_of

Base type of an object
vector-construction

Create vectors
vector-len

Create vectors matching a given length
is_reference

Is an object referencing another?
lang_args

Extract arguments from a call
lang_fn

Extract function from a call
quosure

Create quosures
dots_definitions

Tidy quotation of multiple expressions and dots
with_restarts

Establish a restart point on the stack
as_quosure

Coerce object to quosure
cnd_signal

Signal a condition
as_env

Coerce to an environment
as_utf8_character

Coerce to a character vector and attempt encoding conversion
are_na

Test for missing values
dots_list

Extract dots with splicing semantics
env_bury

Overscope bindings by defining symbols deeper in a scope
env_clone

Clone an environment