Skip to contents

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

Usage

# S3 method for class '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
}

variable

1

2

3

4

5

withinss

23.9

10.6

4.1

3.9

0.7

size

11

9

5

4

3

mpg*

1.0906

-0.4391

-0.0582

-0.9110

-1.3701

cyl*

-1.2249

0.7660

-0.1050

1.0149

1.0149

disp*

-1.0133

0.5522

-0.5703

0.8857

1.8284

hp*

-0.9342

0.1374

-0.2696

1.8313

1.0207

drat*

0.8872

-1.0763

0.4777

0.1467

-1.0160

wt*

-0.9520

0.4020

-0.1924

0.3273

2.1691

qsec*

0.7211

0.0162

-0.3429

-1.5452

-0.0609

(*) Centers

Total sum of squares: 217.0

Total within-cluster sum of squares: 43.2

Total between-cluster sum of squares: 173.8

BSS/TSS ratio: 80.1%

Number of iterations: 2