Cross Tabulation and Table Creation (including empty classes)

table.n(
  x,
  m = max(x, na.rm = TRUE),
  percentage = FALSE,
  weight = NULL,
  parallel = FALSE
)

Arguments

x

R object with classes

m

maximum number of classes

percentage

boolean. If TRUE result is in percentages.

weight

weight for each voxel

parallel

Logical. Can we use parallel computing?

Value

vector with (weighted) counts (including empty classes)

Author

Volker Schmid 2013-2016

Examples

x <- c(1,1,2,2,4,4,4)
table.n(x)
#> 1 2 3 4 
#> 2 2 0 3 
# [1] 2 2 0 3
table.n(x, m=5)
#> 1 2 3 4 5 
#> 2 2 0 3 0 
# [1] 2 2 0 3 0
table.n(x, weight=c(1,1,1,2,.5,.5,.5))
#> [1] 2.0 3.0 0.0 1.5
# [1] 2.0 3.0 0.0 1.5