简体   繁体   中英

Create 360 Degree Analysis in R using ggplot

Is it possible to create a 360-degree analysis in R using ggplot or other similar packages?

Sample data frame below, describing 4 athletes with their speed, strength, skill, stamina and spirit (all between 0 and 5).

name <- c('John', 'Sam', 'Anthony', 'Frank')
speed <- c(1.5, 3, 2, 4)
strength <- c(3, 2.2, 4, 4.5)
skill <- c(4, 1, 2.5, 1.4)
stamina <- c(5, 3.3, 2, 3.9)
spirit <- c(3, 4, 1.4, 2)
df <- data.frame(name, speed, strength, skill, stamina, spirit)
df

My question is: Is there anything in ggplot or other open source packages, that allows me to create a '360 degree analysis' for each of the athlete? Forgive my drawings but this is what I wanted to achieve:

360度分析

This graphical form is often called a radar plot ( stars plots and spider plots are similar): you can do this in base R with ?stars , or in ggplot/tidyverse. (I'm guessing that you want a graphical presentation: normally if someone asked for an "analysis" of these data I would assume they wanted to do some kind of multivariate statistical analysis.)

remotes::install_github("ricardo-bion/ggradar")
library(ggradar)
library(dplyr)
df_scale <- df %>% mutate(across(where(is.numeric),scales::rescale))

I could have gotten something closer to your example by (1) not rescaling the columns and setting grid.max (and possibly other parameters) accordingly; (2) computing the average of the rows.

ggradar(df_scale)

雷达图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM