数据帧的最佳绘图技术

时间:2016-02-27 13:52:19

标签: r ggplot2

enter image description here enter image description here

我试图以捕获所有信息的方式可视化以下数据框。数据框位于

之下
> d
Source: local data frame [16 x 4]
Groups: bowler, wicketKind [?]
       bowler wicketKind  wicketPlayerOut runsConceded
       (fctr)      (chr)            (chr)        (dbl)
1     SJ Harmison     bowled         DI Joyce            0
2     SJ Harmison     caught      DT Johnston            0
3     SJ Harmison     caught      WK McCallan            0
4     SJ Harmison    not-out           nobody           58
5       G Chapple    not-out           nobody           14
6     LE Plunkett    not-out           nobody           48
7      SI Mahmood     caught          JP Bray            0
8      SI Mahmood    not-out           nobody           21
9  PD Collingwood     bowled         AC Botha            0
10 PD Collingwood     caught     PG Gillespie            0
11 PD Collingwood    not-out           nobody           26
12  JWM Dalrymple    not-out           nobody           51
13  JWM Dalrymple    stumped D Langford-Smith            0
14        IR Bell     caught         AR White            0
15        IR Bell     caught       KJ O'Brien            0
16        IR Bell    not-out           nobody           39

我尝试了以下

ggplot(data=d,aes(x=bowler,y=runsConceded)) + geom_bar(stat="identity")
ggplot(data=d,aes(x=bowler,y=wicketKind,fill=wicketPlayerOut)) + geom_bar(stat="identity")

 barchart(wicketPlayerOut~runsConceded|bowler,data=d)

是否可以在单个图中捕获所有列     with(bowler,wicketKind,wicketPlayerOut)vs max(runsConceded)

或使用wicketKind,wicketPlayerOut和max(runsConceded)的不同投球手的多个图表

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您可以使用不同的映射来获得所需的绘图。尝试(在aes内)xycolor和名为facet_wrap()的geom。