Quote expressions

These functions support quasiquotation. They return quosures or raw expressions.

quo new_quosure enquo

Create quosures

dots_definitions quos is_quosures

Tidy quotation of multiple expressions and dots

expr enexpr exprs

Raw quotation of an expression

UQ UQE !! UQS

Quasiquotation of an expression

Evaluate expressions

eval_tidy

Evaluate an expression tidily

eval_bare

Evaluate an expression in an environment

invoke

Invoke a function with a list of arguments

with_env locally

Evaluate an expression within a given environment

Symbols

sym syms

Create a symbol or list of symbols

is_symbol

Is object a symbol?

Calls

lang

Create a call

is_lang is_unary_lang is_binary_lang

Is object a call?

lang_modify

Modify the arguments of a call

lang_standardise

Standardise a call

lang_fn

Extract function from a call

lang_name

Extract function name of a call

lang_head lang_tail

Return the head or tail of a call object

lang_args lang_args_names

Extract arguments from a call

is_callable

Is an object callable?

switch_lang coerce_lang lang_type_of

Dispatch on call type

Expressions

is_expr is_syntactic_literal is_symbolic

Is an object an expression?

expr_label expr_name expr_text

Turn an expression to a label

set_expr get_expr

Set and get an expression

parse_expr parse_exprs parse_quosure parse_quosures

Parse R code

expr_interp

Process unquote operators in a captured expression

exprs_auto_name quos_auto_name

Ensure that list of expressions are all named

Quosures

quo new_quosure enquo

Create quosures

is_quosure is_quosureish

Is an object a quosure or quosure-like?

as_quosure as_quosureish

Coerce object to quosure

quo_is_missing quo_is_symbol quo_is_lang quo_is_symbolic quo_is_null

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

quo_expr quo_label quo_text quo_name

Splice a quosure and format it into string or label

dots_definitions quos is_quosures

Tidy quotation of multiple expressions and dots

exprs_auto_name quos_auto_name

Ensure that list of expressions are all named

Formulas

new_formula

Create a formula

is_formula is_bare_formula is_formulaish

Is object a formula?

f_rhs & - f_lhs f_env

Get or set formula components

f_text f_name f_label

Turn RHS of formula into a string or label

Pairlists and language nodes

node node_car node_cdr node_caar node_cadr node_cdar node_cddr mut_node_car mut_node_cdr mut_node_caar mut_node_cadr mut_node_cdar mut_node_cddr node_tag mut_node_tag

Helpers for pairlist and language nodes

as_pairlist

Coerce to pairlist

is_pairlist

Is object a node or pairlist?

duplicate

Duplicate an R object

Functions

new_function

Create a function

fn_fmls fn_fmls_names fn_fmls_syms

Extract arguments from a function

is_function is_closure is_primitive is_primitive_eager is_primitive_lazy

Is object a function?

prim_name

Name of a primitive function

fn_env & -

Return the closure environment of a function

as_function as_closure

Convert to function or closure

Environments

env child_env

Create a new environment

as_env

Coerce to an environment

env_parent env_tail env_parents

Get parent environments

env_depth

Depth of an environment chain

get_env set_env

Get or set the environment of an object

env_bind env_bind_exprs env_bind_fns

Bind symbols to objects in an environment

env_bury

Overscope bindings by defining symbols deeper in a scope

env_unbind

Remove bindings from an environment

env_has

Does an environment have or see bindings?

env_get

Get an object from an environment

env_names

Names of symbols bound in an environment

env_clone

Clone an environment

env_inherits

Does environment inherit from another environment?

is_env is_bare_env

Is object an environment?

Search path and namespaces

scoped_env pkg_env pkg_env_name scoped_names scoped_envs is_scoped base_env global_env

Scoped environments

empty_env

Get the empty environment

ns_env ns_imports_env ns_env_name

Get the namespace of a package

is_installed

Is a package installed in the library?

Create vectors

Atomic vector constructors have implicit splicing (i.e. splice lists automatically), while the list constructor has explicit splicing.

lgl int dbl cpl chr bytes ll

Create vectors

string

Create a string

lgl_along int_along dbl_along chr_along cpl_along raw_along bytes_along list_along rep_along

Create vectors matching the length of a given vector

lgl_len int_len dbl_len chr_len cpl_len raw_len bytes_len list_len

Create vectors matching a given length

Coerce vectors

These coercers skip S3 dispatch and have stricter implicit coercion rules.

as_logical as_integer as_double as_complex as_character as_string as_list

Coerce an object to a base type

as_bytes

Coerce to a raw vector

Flatten and squash vectors

flatten flatten_lgl flatten_int flatten_dbl flatten_cpl flatten_chr flatten_raw squash squash_lgl squash_int squash_dbl squash_cpl squash_chr squash_raw flatten_if squash_if

Flatten or squash a list of lists into a simpler vector

splice is_spliced is_spliced_bare

Splice a list within a vector

Vectors tools

prepend

Prepend a vector

modify

Modify a vector

seq2 seq2_along

Increasing sequence of integers in an interval

Missing values

missing

Missing values

are_na is_na is_lgl_na is_int_na is_dbl_na is_chr_na is_cpl_na

Test for missing values

Attributes

set_attrs mut_attrs

Add attributes to an object

set_names

Set names of a vector

names2

Get names of a vector

is_named is_dictionaryish have_name

Is object named?

has_name

Does an object have an element with this name?

has_length

How long is an object?

Encoding

as_utf8_character as_native_character as_utf8_string as_native_string

Coerce to a character vector and attempt encoding conversion

set_chr_encoding chr_encoding set_str_encoding str_encoding

Set encoding of a string or character vector

mut_utf8_locale mut_latin1_locale mut_mbcs_locale

Set the locale's codeset for testing

Vectors and lists predicates

is_list is_atomic is_vector is_integer is_double is_character is_logical is_raw is_bytes is_null

Type predicates

is_scalar_list is_scalar_atomic is_scalar_vector is_scalar_integer is_scalar_double is_scalar_character is_scalar_logical is_scalar_raw is_string is_scalar_bytes

Scalar type predicates

is_bare_list is_bare_atomic is_bare_vector is_bare_double is_bare_integer is_bare_numeric is_bare_character is_bare_logical is_bare_raw is_bare_string is_bare_bytes

Bare type predicates

is_empty

Is object an empty vector or NULL?

is_integerish is_bare_integerish is_scalar_integerish

Is a vector integer-like?

Other R types and objects predicates

is_list is_atomic is_vector is_integer is_double is_character is_logical is_raw is_bytes is_null

Type predicates

is_true is_false

Is object identical to TRUE or FALSE?

is_scalar_list is_scalar_atomic is_scalar_vector is_scalar_integer is_scalar_double is_scalar_character is_scalar_logical is_scalar_raw is_string is_scalar_bytes

Scalar type predicates

is_bare_list is_bare_atomic is_bare_vector is_bare_double is_bare_integer is_bare_numeric is_bare_character is_bare_logical is_bare_raw is_bare_string is_bare_bytes

Bare type predicates

is_copyable

Is an object copyable?

type_of

Base type of an object

switch_type coerce_type switch_class coerce_class

Dispatch on base types

friendly_type

Format a type for error messages

Operators

%||%

Default value for NULL

%|%

Replace missing values

%@%

Infix attribute accessor

:= is_definition new_definition

Definition operator

Capture dots

Capture dots with different kinds of splicing semantics.

dots_list dots_splice

Extract dots with splicing semantics

dots_values

Evaluate dots with preliminary splicing

dots_definitions quos is_quosures

Tidy quotation of multiple expressions and dots

dots_n

How many arguments are currently forwarded in dots?

Tidy evaluation and overscoping

Most of the time you only need eval_tidy(), but these functions can be useful if you are writing your own grammar.

tidyeval-data

Data pronoun for tidy evaluation

eval_tidy_

Tidy evaluation in a custom environment

as_overscope new_overscope overscope_eval_next overscope_clean

Create a dynamic scope for tidy evaluation

as_dictionary is_dictionary

Create a dictionary

Function arguments

arg_match

Match an argument to a character vector

missing_arg is_missing maybe_missing

Generate or handle a missing argument

Call and context stacks

The call stack is a subset of the context stack where nuisance frames due to lazy evaluation are removed. It is easier to analyse than the full context stack. Stacks are list of frames, which are S3 objects with a nice print method for visualing call frames.

global_frame current_frame ctxt_frame call_frame ctxt_depth call_depth ctxt_stack call_stack

Call stack information

is_stack is_eval_stack is_call_stack

Is object a stack?

is_frame

Is object a frame?

caller_env caller_frame caller_fn

Get the environment of the caller frame

frame_position

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

stack_trim

Trim top call layers from the evaluation stack

return_from return_to

Jump to or from a frame

call_inspect

Inspect a call

Create conditions

These helpers make it easy to create typed conditions.

new_cnd cnd_error cnd_warning cnd_message

Create a condition object

is_condition

Is object a condition?

Signal conditions

abort warn inform

Signal an error, warning, or message

cnd_signal cnd_abort

Signal a condition

Restarts

with_restarts

Establish a restart point on the stack

rst_list rst_exists rst_jump rst_maybe_jump

Restarts utilities

rst_abort

Jump to the abort restart

rst_muffle

Jump to a muffling restart

Condition handlers

with_handlers

Establish handlers on the stack

exiting inplace

Create an exiting or in place handler

restarting

Create a restarting handler