drop-rvar-method: Drop redundant dimensions

drop,rvar-methodR Documentation

Drop redundant dimensions

Description

Delete the dimensions of an rvar which are of size one. See base::drop()

Usage

## S4 method for signature 'rvar'
drop(x)

Arguments

x

(rvar) an rvar.

Value

An rvar with the same length as x, but where any entry equal to 1 in dim(x) has been removed. The exception is if dim(x) == 1, in which case dim(drop(x)) == 1 as well (this is because rvars, unlike numerics, never have NULL dimensions).

Examples

# Sigma is a 3x3 covariance matrix
Sigma <- as_draws_rvars(example_draws("multi_normal"))$Sigma
Sigma

Sigma[1, ]

drop(Sigma[1, ])

# equivalently ...
Sigma[1, drop = TRUE]


posterior documentation built on Nov. 2, 2023, 5:56 p.m.