我有以下数据:
dat <- tribble(
~name, ~current_hit, ~future_hit, ~current_raw_power, ~future_raw_power, ~current_game_power, ~future_game_power,
"Jackson Holliday", 45, 60, 50, 60, 25, 60,
"James Wood", 30, 35, 70, 80, 55, 80)
我期望的产出是:
player names current future
"Jackson Holliday" hit 45 60
"Jackson Holliday" game_power 50 60
"Jackson Holliday" raw_power 25 60
"James Wood" hit 30 35
"James Wood" raw_power 70 80
"James Wood" game_power 55 80
I ve tried referencing a similar question here: pivot_longer into multiple columns. However, this use case is slightly different from mine and the use of regular expressions is a bit beyond my coding skills at the moment.
我的用意是,在后来的数据集中增加现时/未来数字,但我从一个更简单的例子开始,我可以据此扩大解决办法。
赞赏一切帮助!