produce a flextable describing a kmeans object. The function is only using package 'broom' that provides the data presented in the resulting flextable.

# S3 method for kmeans
as_flextable(x, digits = 4, ...)

Arguments

x

a kmeans() object

digits

number of digits for the numeric columns

...

unused argument

Examples

if(require("stats")){
  cl <- kmeans(scale(mtcars[1:7]), 5)
  ft <- as_flextable(cl)
  ft
}
#> a flextable object.
#> col_keys: `variable`, `dummy1`, `1@zz`, `dummy2`, `2@zz`, `dummy3`, `3@zz`, `dummy4`, `4@zz`, `dummy5`, `5@zz` 
#> header has 1 row(s) 
#> body has 9 row(s) 
#> original dataset sample: 
#>   variable    value@1   value@2     value@3    value@4    value@5 zz@1 zz@2
#> 8 withinss  5.4071414  7.760190 12.80150335  0.6810421 20.1305165          
#> 7     size  5.0000000  6.000000  7.00000000  3.0000000 11.0000000          
#> 5      mpg  0.4130407  1.655239 -0.05770215 -1.3700619 -0.6802308          
#> 1      cyl -1.2248578 -1.224858 -0.10498781  1.0148821  1.0148821          
#> 2     disp -0.8342986 -1.162445 -0.38250838  1.8284157  0.7580429          
#>   zz@3 zz@4 zz@5   key_type dummy1 1@zz dummy2 2@zz dummy3 3@zz dummy4 4@zz
#> 8                Statistics                                                
#> 7                Statistics                                                
#> 5                   Centers                                                
#> 1                   Centers                                                
#> 2                   Centers                                                
#>   dummy5 5@zz
#> 8            
#> 7            
#> 5            
#> 1            
#> 2