1
以下是第一行15我的數據:如何在R中使用多個標準進行繪圖?
> head(df,15)
frame.group class lane veh.count mean.speed
1 [22,319] 2 5 9 23.40345
2 [22,319] 2 4 9 24.10870
3 [22,319] 2 1 11 14.70857
4 [22,319] 2 3 8 20.88783
5 [22,319] 2 2 6 16.75327
6 (319,616] 2 5 15 22.21671
7 (319,616] 2 2 16 23.55468
8 (319,616] 2 3 12 22.84703
9 (319,616] 2 4 14 17.55428
10 (319,616] 2 1 13 16.45327
11 (319,616] 1 1 1 42.80160
12 (319,616] 1 2 1 42.34750
13 (616,913] 2 5 18 30.86468
14 (319,616] 3 3 2 26.78177
15 (616,913] 2 4 14 32.34548
「frame.group」包含的時間間隔,「類」是車輛類即1 =摩托車,2 =汽車,3 =卡車和「車道」包含車道號碼。我想創建3個散點圖,frame.group爲x軸,mean.speed爲y軸,每個類爲1。在一個車輛等級的散點圖中,汽車,我想要5個地塊,即每個車道一個。我嘗試以下:
cars <- subset(df, class==2)
by(cars, lane, FUN = plot(frame.group, mean.speed))
有兩個問題:如預期即5繪製5個不同泳道
1)R不繪製。 2)只有一個被繪製出來,這也可能是因爲我用間隔而不是數字作爲x軸。
我該如何解決上述問題?請幫忙。
謝謝。到目前爲止,我一直在避免使用ggplot2。但現在是學習它的時候了。你給了我這個動機,謝謝。 –