r - 使用 ggplot 在 R 中创建 360 度分析
问题描述
是否可以使用 ggplot 或其他类似软件包在 R 中创建 360 度分析?
下面的示例数据框,描述了 4 名运动员的速度、力量、技能、耐力和精神(均在 0 到 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
我的问题是:ggplot 或其他开源软件包中是否有任何东西可以让我为每个运动员创建“360 度分析”?原谅我的画,但这是我想要实现的:
解决方案
这种图形形式通常称为雷达图(星图和蜘蛛图类似):您可以在基础 R 中使用?stars
或在 ggplot/tidyverse 中执行此操作。(我猜你想要一个图形表示:通常如果有人要求对这些数据进行“分析”,我会假设他们想做某种多元统计分析。)
remotes::install_github("ricardo-bion/ggradar")
library(ggradar)
library(dplyr)
df_scale <- df %>% mutate(across(where(is.numeric),scales::rescale))
grid.max
我可以通过(1)不重新调整列并相应地设置(可能还有其他参数)来更接近您的示例;(2) 计算行的平均值。
ggradar(df_scale)
推荐阅读
- sql - 获取多个日期范围之间的值总和
- wordpress - Wordpress 下拉菜单(引导程序)
- php - 如何使用 PHP 打印这个数字序列?
- python - 如何保存连体模型的基础网络?
- php - 将产品简短描述添加到 WooCommerce 电子邮件通知
- python - Heroku 计划的 Python 脚本每隔几天就会崩溃一次
- react-native - React 检测到 StackNavigator 调用的 Hook 顺序发生了变化
- python - 如何创建 0 维 tf.Variable?
- php - 如何在 SQL 中自动填充多对多表
- html - 如何删除导航栏中按钮的悬停行为?