get_dim: Get single column or row without dropping names

get_dimR Documentation

Get single column or row without dropping names

Description

Subset matrix dropping dimension but without dropping dimname (as done by `[` by default).

Usage

get_col(matrix, rows, col)

get_row(matrix, row, cols)

Arguments

matrix

matrix.

rows

numeric; rows to subset; like with `[`, this argument can be left empty to designate all rows.

col

integer; single column to subset.

row

integer; single row to subset.

cols

numeric; columns to subset; like with `[`, this argument can be left empty to designate all columns.

Value

A named vector object.

Author(s)

Carles \Breto

Examples

m <- matrix(NA,dimnames=list('r1','c1'))
m[1,1] # = NA; R removes both names
get_col(m,rows=1,col=1) # = c(r1=NA) keeps colname
get_row(m,row=1,cols=1) # = c(c1=NA) keeps rowname

cbreto/panelPomp documentation built on Sept. 15, 2024, 10:42 p.m.