Calculates x-y coordinates for a set of radial axes (one per variable being plotted in radar plot)

CalculateAxisPath(var.names, min, max)

Arguments

var.names

list of variables to be plotted on radar plot

min

MININUM value required for the plotted axes (same value will be applied to all axes)

max

MAXIMUM value required for the plotted axes (same value will be applied to all axes)

Value

a dataframe of the calculated axis paths

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
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"
var.names <- colnames(plot.data)[-1]
grid.min = 0
grid.max = 1
centre.y = grid.min - ((1 / 9) * (grid.max - grid.min))
CalculateAxisPath(var.names, grid.min + abs(centre.y), grid.max + abs(centre.y))
#>    axis.no           x           y
#> 1        1  0.00000000  0.11111111
#> 2        1  0.00000000  1.11111111
#> 3        2  0.07142085  0.08511605
#> 4        2  0.71420846  0.85116049
#> 5        3  0.10942308  0.01929424
#> 6        3  1.09423084  0.19294242
#> 7        4  0.09622504 -0.05555556
#> 8        4  0.96225045 -0.55555556
#> 9        5  0.03800224 -0.10441029
#> 10       5  0.38002238 -1.04410291
#> 11       6 -0.03800224 -0.10441029
#> 12       6 -0.38002238 -1.04410291
#> 13       7 -0.09622504 -0.05555556
#> 14       7 -0.96225045 -0.55555556
#> 15       8 -0.10942308  0.01929424
#> 16       8 -1.09423084  0.19294242
#> 17       9 -0.07142085  0.08511605
#> 18       9 -0.71420846  0.85116049