Learn R Programming

posterior (version 1.6.0)

drop,rvar-method: Drop redundant dimensions

Description

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

Usage

# S4 method for rvar
drop(x)

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).

Arguments

x

(rvar) an rvar.

Examples

Run this code
# 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]

Run the code above in your browser using DataLab