Finds the mode value(s) for each column in a matrix or a data frame.

ct_modeCol(x)

Arguments

x

A matrix or a data frame.

Value

A matrix with the mode value(s) for each column in x. The rownames are the colnames of x.

Examples

dataTest=cbind(c(10,10,50,12), c(100, 101, 102, 102), c(1, 1, 5,4))
colnames(dataTest)=c("Variable 1", "Variable 2", "Variable 3")
ct_modeCol(dataTest)
#> Variable 1 Variable 2 Variable 3 
#>         10        102          1 
dataTest=cbind(c(10,10,50,12,50), c(100, 101, 102, 102, 103), c(1, 1, 5,4, 4))
colnames(dataTest)=c("Variable 1", "Variable 2", "Variable 3")
ct_modeCol(dataTest)
#>            Mode Mode
#> Variable 1   10   50
#> Variable 2  102   NA
#> Variable 3    1    4