我有一个看起来像这样的数据框:
df <- data.frame(
CM = c("Jan", "Jan", "Jan", "Feb", "Feb", "Mar", "Mar", "Mar", "Apr", "Apr", "Apr"),
PM = c("Jan", "Feb", "Mar", "Feb", "Mar", "Mar", "Apr", "May", "Apr", "May", "Jun"),
Value = c(8, 5, 6, 8, 3, 4, 7, 6, 7, 1, 3))
< p >< em >(其中CM表示当前月份,PM表示预测月份)
df
CM PM Value
Jan Jan 8*
Jan Feb 5
Jan Mar 6
Feb Feb 8*
Feb Mar 3
Mar Mar 4*
Mar Apr 7
Mar May 6
Apr Apr 7*
Apr May 1
Apr Jun 3
我想将这个整洁的数据转换成一个错开的图表。
Prediction
Jan Feb Mar Apr May Jun ...
M|Jan 8* 5 6
O|Feb 8* 3
N|Mar 4* 7 6
T|Apr 7* 1 3
H|...