我在创建分组条形图时遇到了困难。这是我第一次使用R中散点图以外的任何东西。有团队,以及他们放弃位置的点(代码下方)。 C,D和W.离开r-graph-gallery获取下面的代码。
library(ggplot2)
positions=rep(c("C","W","D"))
ggplot(data=stats, aes(fill=positions, y=0,200,x=PtsAgRdTm))+
geom_bar(position = "dodge", stat = "indentity")
以下df
与stats
相比,转换为data
。
PtsAgRdTm C D W
ANH 57.73 65.08 56.08
ARI 33 29.24 26.99
BOS 56.64 44.97 56.15
BUF 35.36 31.04 38.35
CAR 42.6 49.79 78.03
CLS 38.23 53.16 67.92
CGY 56.19 54.87 78.54
CHI 37.04 47.93 74.95
COL 54.87 47.83 78.22
DAL 59.05 39.67 33.3
DET 26.11 34.15 71.21
EDM 57.64 53.01 43.14
FLA 71.09 44.85 44.91
LA 53.06 48.62 42.11
MIN 41.86 51.44 51.93
MON 36.6 50 89.02
NJ 26.95 34.64 49.61
NSH 43.12 60.05 83.11
NYI 51.58 46.36 46.99
NYR 75.15 104.19 177.69
OTT 51.01 64.75 75.05
PHI 65.96 54.69 40.56
PIT 42.67 38.08 52.33
SJ 70.83 56.66 44.31
STL 40.51 58.83 81.85
TB 68 50.93 58.22
TOR 71.28 42.17 21.5
VAN 29.81 28.79 41.4
VGK 40.09 43.63 63.49
WPG 49.66 48.09 77.08
WAS 47.68 52.02 70.12