Converts variable values into a set of radial x-y coordinates

CalculateGroupPath(df)

Arguments

df

a dataframe with Col 1 is group ('unique' cluster / group ID of entity) and Col 2-n are v1.value to vn.value - values (e.g. group/cluser mean or median) of variables v1 to v.n

Value

a dataframe of the calculated axis paths

Examples

library(dplyr)
library(scales)
library(tibble)

mtcars_radar <- mtcars %>%
  as_tibble(rownames = "group") %>%
  mutate_at(vars(-group), rescale) %>%
  tail(4) %>%
  select(1:10)
plot.data <- as.data.frame(mtcars_radar)
if(!is.factor(plot.data[, 1])) {
  plot.data[, 1] <- as.factor(as.character(plot.data[, 1]))
  }
names(plot.data)[1] <- "group"
CalculateGroupPath(plot.data)
#>             group           x            y
#> 1    Ferrari Dino  0.00000000  0.395744681
#> 2    Ferrari Dino  0.32139380  0.383022222
#> 3    Ferrari Dino  0.18153478  0.032009479
#> 4    Ferrari Dino  0.37639973 -0.217314488
#> 5    Ferrari Dino  0.13554715 -0.372412744
#> 6    Ferrari Dino -0.10992568 -0.302018314
#> 7    Ferrari Dino -0.10309826 -0.059523810
#> 8    Ferrari Dino  0.00000000  0.000000000
#> 9    Ferrari Dino -0.64278761  0.766044443
#> 10   Ferrari Dino  0.00000000  0.395744681
#> 11 Ford Pantera L  0.00000000  0.229787234
#> 12 Ford Pantera L  0.64278761  0.766044443
#> 13 Ford Pantera L  0.68757219  0.121237528
#> 14 Ford Pantera L  0.64875401 -0.374558304
#> 15 Ford Pantera L  0.23011494 -0.632235588
#> 16 Ford Pantera L -0.14490600 -0.398125971
#> 17 Ford Pantera L  0.00000000  0.000000000
#> 18 Ford Pantera L  0.00000000  0.000000000
#> 19 Ford Pantera L -0.64278761  0.766044443
#> 20 Ford Pantera L  0.00000000  0.229787234
#> 21  Maserati Bora  0.00000000  0.195744681
#> 22  Maserati Bora  0.64278761  0.766044443
#> 23  Maserati Bora  0.56474757  0.099580235
#> 24  Maserati Bora  0.86602540 -0.500000000
#> 25  Maserati Bora  0.12293812 -0.337769698
#> 26  Maserati Bora -0.17988633 -0.494233628
#> 27  Maserati Bora -0.01030983 -0.005952381
#> 28  Maserati Bora  0.00000000  0.000000000
#> 29  Maserati Bora -0.64278761  0.766044443
#> 30  Maserati Bora  0.00000000  0.195744681
#> 31     Volvo 142E  0.00000000  0.468085106
#> 32     Volvo 142E  0.00000000  0.000000000
#> 33     Volvo 142E  0.12257896  0.021613979
#> 34     Volvo 142E  0.17442914 -0.100706714
#> 35     Volvo 142E  0.21277751 -0.584601400
#> 36     Volvo 142E -0.11080018 -0.304421005
#> 37     Volvo 142E -0.42270288 -0.244047619
#> 38     Volvo 142E -0.98480775  0.173648178
#> 39     Volvo 142E -0.64278761  0.766044443
#> 40     Volvo 142E  0.00000000  0.468085106