Skip to contents

s(x, m) gets the size of an object x along margin m.
If m == 0, s() gets the length of an object.
If m > 0, s() gets dim(x)[m] of the object.

Usage

s(x, m = 0L, ...)

# Default S3 method
s(x, m, ...)

Arguments

x

an object

m

the margin.

...

further arguments passed to or from methods.

Value

A numeric scalar.

Examples


x <- array(1:64, c(4,4,3))
print(x)
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    1    5    9   13
#> [2,]    2    6   10   14
#> [3,]    3    7   11   15
#> [4,]    4    8   12   16
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]   17   21   25   29
#> [2,]   18   22   26   30
#> [3,]   19   23   27   31
#> [4,]   20   24   28   32
#> 
#> , , 3
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]   33   37   41   45
#> [2,]   34   38   42   46
#> [3,]   35   39   43   47
#> [4,]   36   40   44   48
#> 
ss <- n(c(s(x, 1), 1), c(s(x, 3), 1))
ss_x(x, ss, c(1,3))
#> , , 1
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]   36   40   44   48
#> [2,]   33   37   41   45
#> 
#> , , 2
#> 
#>      [,1] [,2] [,3] [,4]
#> [1,]    4    8   12   16
#> [2,]    1    5    9   13
#>