size: Vector, Matrix or Data.Frame Size

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/size.R

Description

size is a utility function which determines the dimensions of vectors (coerced to matrices), matrices, arrays, data.frames, and list elements.

Usage

1
  size(x = NULL, n = NULL)

Arguments

x

A R object.

n

A integer indicating the dimension of interest.

Details

size is a wrapper function around dim. It returns the n^th dimension of x if n is provided. If n is not provide, all dimensions will be determined. If x is a list, n is ignored and the dimensions of all elements of x are recursively determined.

Value

Returns a vector or list of dimensions.

Author(s)

Sebastien Bihorel ([email protected])

See Also

dim

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
  a <- 1
  b <- letters[1:6]
  c <- matrix(1:20,nrow=4,ncol=5)
  d <- array(1:40, dim=c(2,5,2,2))
  e <- data.frame(a,b)
  f <- list(a,b,c,d,e)

  size(NULL) # 0 0
  size(NA)   # 1 1
  size(a)    # 1 1
  size(b,2)  # 6
  size(c)    # 4 5
  size(d)    # 2 5 2 2
  size(e,3)  # NA
  size(f)

optimbase documentation built on May 29, 2017, 10:54 a.m.