CalculateGroupPath: Calcule les trajectoires par groupe pour un diagramme en...

Description Usage Arguments Value Source Examples

View source: R/functions.R

Description

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

Usage

1

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

Source

Code adapted from a solution posted by Tony M to https://stackoverflow.com/questions/9614433/creating-radar-chart-a-k-a-star-plot-spider-plot-using-ggplot2-in-r.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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)

sageR documentation built on July 20, 2021, 9:08 a.m.