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 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

5.4

7.8

12.8

0.7

20.1

size

5

6

7

3

11

mpg*

0.4130

1.6552

-0.0577

-1.3701

-0.6802

cyl*

-1.2249

-1.2249

-0.1050

1.0149

1.0149

disp*

-0.8343

-1.1624

-0.3825

1.8284

0.7580

hp*

-0.8093

-1.0383

-0.3559

1.0207

0.8823

drat*

0.4815

1.2252

-0.0203

-1.0160

-0.5972

wt*

-0.4459

-1.3738

-0.1023

2.1691

0.4256

qsec*

1.2173

0.3076

0.0719

-0.0609

-0.7502

(*) Centers

Total sum of squares: 217.0

Total within-cluster sum of squares: 46.8

Total between-cluster sum of squares: 170.2

BSS/TSS ratio: 78.4%

Number of iterations: 2