ggplot2 geom_smooth无效

时间:2016-04-05 10:02:40

标签: r ggplot2

我是R的新手并使用“使用R'发现统计数据”这本书。作为指导。 为了探索我论文的数据,我想制作一些图表,并想知道不同比赛水平的纵向冲刺数据的趋势是什么,所以我写了这个:

plotSprint<- ggplot(SprintLong, aes(time, value, colour=PlayingLevel)) 
plotSprint+geom_point()+geom_smooth()+labs(x="Time", y="30m Sprint Time (s)")

问题是该图显示了所有数据点而不是平滑线,尽管标签变得更灰,并且对于不同的播放级别使用线而不是点。我不知道在图表中没有平滑线条的原因是什么。有人能帮助我吗?

编辑: 我不确定如何正确包含我的数据,对不起。变量时间来自另一个变量:

SprintLong$time <- recode(SprintLong$variable,"'T1SprintBestTime30m'=1;'T2SprintBestTime30m'=2;'T3SprintBestTime30m'=3; 'T4SprintBestTime30m'=4;'T5SprintBestTime30m'=5;'T6SprintBestTime30m'=6")

         time value         PlayingLevel
1           1  4.01 Association Football
2           1  4.12                  NPL
3           1  5.52 Association Football
4           1  5.04 Association Football
5           1  4.13 Association Football
6           1  4.31 Association Football
7           1  4.18 Association Football
8           1  4.19 Association Football
9           1  4.03                  NPL
10          1  5.30 Association Football
11          1  4.36 Association Football
12          1  4.13 Association Football
13          1  4.22         State League
14          1  4.52         State League
15          1  4.55                  NPL
16          1  4.02 Association Football
17          1  3.96 Association Football
18          1  4.83 Association Football
19          1  4.52 Association Football
20          1  4.05         State League
21          1  4.51 Association Football
22          1    NA Association Football
23          1  4.29 Association Football
24          1  4.05 Association Football
25          1  4.79         State League
26          1  4.08                  NPL
27          1  5.02 Association Football
28          1    NA Association Football
29          1  4.29 Association Football
30          1  4.40 Association Football
31          2  4.48 Association Football
32          2    NA                  NPL
33          2  4.39 Association Football
34          2  4.81 Association Football
35          2  4.22 Association Football
36          2  4.38 Association Football
37          2    NA Association Football
38          2  4.24 Association Football
39          2  4.11                  NPL
40          2  5.14 Association Football
41          2    NA Association Football
42          2    NA Association Football
43          2  4.13         State League
44          2  4.52         State League
45          2  4.65                  NPL
46          2  4.18 Association Football
47          2  4.20 Association Football
48          2  4.80 Association Football
49          2  4.39 Association Football
50          2  3.97         State League
51          2  4.44 Association Football
52          2  4.21 Association Football
53          2    NA Association Football
54          2  4.33 Association Football
55          2  4.87         State League
56          2  4.14                  NPL
57          2  5.13 Association Football
58          2  4.55 Association Football
59          2  4.30 Association Football
60          2  4.41 Association Football
61          3  4.03 Association Football
62          3    NA                  NPL
63          3  5.24 Association Football
64          3  4.86 Association Football
65          3  4.27 Association Football
66          3  4.25 Association Football
67          3    NA Association Football
68          3  4.27 Association Football
69          3  4.12                  NPL
70          3  5.38 Association Football
71          3  4.49 Association Football
72          3  4.23 Association Football
73          3  4.17         State League
74          3  4.59         State League
75          3    NA                  NPL
76          3    NA Association Football
77          3  4.30 Association Football
78          3    NA Association Football
79          3  4.56 Association Football
80          3    NA         State League
81          3  4.56 Association Football
82          3  4.81 Association Football
83          3    NA Association Football
84          3  4.20 Association Football
85          3  4.89         State League
86          3    NA                  NPL
87          3    NA Association Football
88          3  4.64 Association Football
89          3  4.36 Association Football
90          3  4.63 Association Football
91          4  4.13 Association Football
92          4  4.20                  NPL
93          4  5.15 Association Football
94          4    NA Association Football
95          4    NA Association Football
96          4  4.31 Association Football
97          4    NA Association Football
98          4  4.30 Association Football
99          4    NA                  NPL
100         4    NA Association Football
101         4  4.41 Association Football
102         4  4.28 Association Football
103         4  4.27         State League
104         4  4.62         State League
105         4    NA                  NPL
106         4  4.27 Association Football
107         4  4.15 Association Football
108         4  4.85 Association Football
109         4  4.64 Association Football
110         4    NA         State League
111         4    NA Association Football
112         4    NA Association Football
113         4  4.34 Association Football
114         4  4.16 Association Football
115         4    NA         State League
116         4  4.16                  NPL
117         4    NA Association Football
118         4  4.66 Association Football
119         4  4.36 Association Football
120         4  4.56 Association Football
121         5    NA Association Football
122         5  4.19                  NPL
123         5  5.27 Association Football
124         5  5.16 Association Football
125         5    NA Association Football
126         5    NA Association Football
127         5    NA Association Football
128         5  4.34 Association Football
129         5    NA                  NPL
130         5  5.27 Association Football
131         5  4.47 Association Football
132         5  4.20 Association Football
133         5    NA         State League
134         5    NA         State League
135         5  4.72                  NPL
136         5    NA Association Football
137         5    NA Association Football
138         5  4.73 Association Football
139         5  4.59 Association Football
140         5  4.11         State League
141         5    NA Association Football
142         5  4.94 Association Football
143         5  4.21 Association Football
144         5  4.18 Association Football
145         5  4.83         State League
146         5    NA                  NPL
147         5    NA Association Football
148         5  4.66 Association Football
149         5  4.20 Association Football
150         5  4.40 Association Football
151         6  4.11 Association Football
152         6  4.27                  NPL
153         6  5.21 Association Football
154         6  5.03 Association Football
155         6    NA Association Football
156         6  4.16 Association Football
157         6  4.34 Association Football
158         6  4.21 Association Football
159         6  4.05                  NPL
160         6    NA Association Football
161         6  4.41 Association Football
162         6  4.22 Association Football
163         6  4.10         State League
164         6  4.43         State League
165         6  4.78                  NPL
166         6    NA Association Football
167         6  4.10 Association Football
168         6  4.69 Association Football
169         6  4.62 Association Football
170         6    NA         State League
171         6    NA Association Football
172         6    NA Association Football
173         6    NA Association Football
174         6  4.16 Association Football
175         6  4.61         State League
176         6    NA                  NPL
177         6    NA Association Football
178         6  4.59 Association Football
179         6  4.35 Association Football
180         6  4.52 Association Football

0 个答案:

没有答案