在 table 中显示具有 1 个以上变量的数据的最佳方式是什么?

What's the best way to display data with more than 1 variable in a table?

我有以下数据。

我正在尝试找到以 table 格式(在 R 中)可视化此数据的最佳方法,但我似乎找不到易于阅读或易于比较的选项。有什么建议吗?

如果数据在 df1 中,则以下命令将其整形为宽格式:

library(tidyr)
library(dplyr)

df1 %>% 
  pivot_wider(id_cols = Country, 
              names_from = Year, 
              values_from=c(Score, GDP))

# A tibble: 2 x 11
  Country Score_2015 Score_2016 Score_2017 Score_2018 Score_2019 GDP_2015 GDP_2016 GDP_2017 GDP_2018 GDP_2019
  <fct>        <int>      <int>      <int>      <int>      <int>    <int>    <int>    <int>    <int>    <int>
1 Afghan           1          3          5          7          9      101      103      105      107      109
2 Swiss            2          4          6          8         10      102      104      106      108      110

看起来很宽,但格式更好,可以看起来像这样:


数据:

df1 <- data.frame(Country=rep(c("Afghan","Swiss"),5),
                 Year=rep(2015:2019, each=2),
                 Score=c(1:10), GDP=101:110)