powered by
Subset matrix dropping dimension but without dropping dimname (as done by `[` by default).
`[`
get_col(matrix, rows, col)get_row(matrix, row, cols)
get_row(matrix, row, cols)
A named vector object.
vector
matrix.
numeric; rows to subset; like with `[`, this argument can be left empty to designate all rows.
integer; single column to subset.
integer; single row to subset.
numeric; columns to subset; like with `[`, this argument can be left empty to designate all columns.
Carles Bretó
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
Run the code above in your browser using DataLab