对于分析,我想data
从以下转换:
data <- data.frame(
Customer = c("A", "A", "B", "B", "C", "C", "C"),
Product = c("X", "Y", "X", "Z", "X", "Y", "Z"),
Value = c(10, 15, 5, 10, 20, 5, 10)
)
data
# Customer Product Value
# 1 A X 10
# 2 A Y 15
# 3 B X 5
# 4 B Z 10
# 5 C X 20
# 6 C Y 5
# 7 C Z 10
至:
Product Product Sum Value
-------|-------|---------
X |Y |50
X |Z |45
Y |Z |15
基本上,我想获得客户中每个产品组合的价值总和。我想它可以在 reshape 包的帮助下工作,但我无法让它工作。
谢谢你的时间。