我的data.frame是这样的:
ï..Date Open High Low Close
1 29-Apr-16 85525.08 85664.35 84837.94 85327.80
2 28-Apr-16 85467.41 85676.38 84763.17 85477.83
3 27-Apr-16 85877.39 86121.04 85291.50 85374.19
4 26-Apr-16 85347.24 85938.32 85042.85 85756.42
5 25-Apr-16 85573.44 85851.23 84984.19 85109.37
6 22-Apr-16 85847.37 85929.31 85150.63 85828.66
7 21-Apr-16 85936.57 86450.04 85117.74 85670.80
8 20-Apr-16 86008.52 86931.34 85271.54 85550.21
9 19-Apr-16 86607.43 86693.50 85806.74 86250.97
10 18-Apr-16 85180.38 86386.70 84997.66 86343.65
11 15-Apr-16 85970.85 86188.01 84807.93 85573.25
12 14-Apr-16 85749.81 86254.50 85340.41 85784.95
13 13-Apr-16 84151.90 85808.84 84009.16 85696.67
14 12-Apr-16 83859.36 84429.97 83263.83 83719.80
15 11-Apr-16 82630.54 84101.43 82301.42 83987.53
16 8-Apr-16 81451.03 82576.11 80884.03 82502.11
17 7-Apr-16 82008.12 82252.59 81080.72 81164.66
18 6-Apr-16 82906.10 83026.05 81511.27 81511.27
19 5-Apr-16 83620.50 83701.04 82465.04 82964.08
20 4-Apr-16 82762.54 83872.91 82599.87 83872.91
21 1-Apr-16 82987.20 83054.63 81931.92 82359.44
22 31-Mar-16 82917.50 83446.84 82486.84 83268.04
23 30-Mar-16 82374.98 83041.35 82299.46 82917.75
24 29-Mar-16 81716.75 82273.33 81522.90 81733.62
25 28-Mar-16 81494.08 81731.07 80873.10 81344.55
26 25-Mar-16 81423.37 81753.38 81289.85 81356.45
27 24-Mar-16 80297.44 81389.59 80121.03 81358.38
28 23-Mar-16 81549.27 81735.04 80171.70 80383.69
29 22-Mar-16 82853.03 82853.03 80983.00 81766.14
30 21-Mar-16 82775.57 83523.69 82436.63 83402.73
31 18-Mar-16 81482.74 82943.44 81221.19 82943.44
32 17-Mar-16 80477.35 81389.27 80396.17 81377.13
33 16-Mar-16 79168.74 79574.05 78419.53 79369.24
34 15-Mar-16 80087.19 80091.21 78774.60 79031.07
35 14-Mar-16 79203.09 80114.60 79179.92 80110.88
36 11-Mar-16 79565.89 79613.12 78743.46 79380.18
37 10-Mar-16 78856.10 79674.05 78505.03 79024.69
38 9-Mar-16 77628.86 78738.19 77398.35 78738.19
39 8-Mar-16 77284.19 78143.92 77157.99 77682.88
40 7-Mar-16 77349.55 77989.76 77150.42 77483.85
41 4-Mar-16 76943.53 77191.14 76163.94 77191.14
42 3-Mar-16 77062.56 77527.33 76466.08 76828.32
43 2-Mar-16 76635.66 77096.52 76415.08 76787.95
44 1-Mar-16 75949.08 76184.62 75642.13 75955.43
45 29-Feb-16 74709.59 75954.83 74423.81 75814.41
46 26-Feb-16 75570.61 76017.39 74835.60 74929.02
47 25-Feb-16 74551.70 75504.17 74351.13 75201.89
48 24-Feb-16 75638.72 75705.44 73916.02 74067.21
49 23-Feb-16 74854.64 75923.81 74674.31 75499.76
50 22-Feb-16 73656.62 74893.90 73566.40 74893.90
51 19-Feb-16 73400.95 73455.61 72671.16 73015.42
52 18-Feb-16 72709.21 73446.47 72322.33 73446.47
53 17-Feb-16 70922.65 72855.79 70653.59 72805.12
54 16-Feb-16 71586.49 71815.85 70807.45 70949.22
55 15-Feb-16 71275.31 71566.39 69436.07 71008.09
56 12-Feb-16 71331.83 71541.79 70895.67 70937.40
57 11-Feb-16 71116.39 71281.57 69889.81 70941.65
58 10-Feb-16 71672.10 72249.88 70856.37 71614.22
59 9-Feb-16 71520.33 71798.27 70373.47 71415.16
60 8-Feb-16 74457.35 74656.23 72005.24 72005.24
61 5-Feb-16 74485.66 74767.42 74033.33 74203.54
62 4-Feb-16 74150.41 74740.40 73962.86 74505.36
63 3-Feb-16 72174.76 73629.82 72015.18 73267.44
64 2-Feb-16 73651.59 73911.49 72506.16 72506.16
65 1-Feb-16 73496.15 73514.82 72793.71 73447.67
66 29-Jan-16 73122.72 73506.60 73080.24 73481.09
67 28-Jan-16 72431.77 72960.91 72320.67 72427.41
68 27-Jan-16 71819.83 72683.67 71775.15 72052.86
69 26-Jan-16 70144.50 71838.70 69925.09 71808.91
70 25-Jan-16 70761.85 71087.97 70123.01 70539.01
71 22-Jan-16 69487.09 70392.47 69255.28 70243.91
72 21-Jan-16 69657.63 69777.08 68230.47 68567.89
73 20-Jan-16 70604.62 70785.60 69595.27 69603.95
74 19-Jan-16 71666.37 71827.39 70786.19 71073.16
75 18-Jan-16 71463.60 71521.46 70845.24 71039.68
76 15-Jan-16 71984.02 72274.51 70628.02 71062.00
77 14-Jan-16 72206.40 72651.44 71308.91 71940.56
78 13-Jan-16 72106.05 73010.85 72030.21 72508.72
79 12-Jan-16 71033.30 72100.10 70516.46 71740.41
80 11-Jan-16 70397.28 71621.86 70111.51 71048.98
81 8-Jan-16 71868.20 72131.92 70407.76 70613.20
82 7-Jan-16 70600.10 71640.24 69687.85 71495.93
83 6-Jan-16 70379.59 71267.13 69713.49 71197.94
84 5-Jan-16 71055.53 71253.47 69395.82 70688.10
85 4-Jan-16 70677.98 70816.41 69880.43 70518.35
86 31-Dec-15 73305.02 73372.07 71433.59 71726.99
87 30-Dec-15 73939.63 74004.94 73064.64 73200.69
88 29-Dec-15 74430.00 74527.68 73692.94 73912.61
89 28-Dec-15 74436.85 74953.61 74193.26 74243.17
90 25-Dec-15 74150.66 74227.85 73994.66 74189.53
91 24-Dec-15 74246.76 74393.68 73864.96 74050.35
92 23-Dec-15 73531.61 74498.61 73531.18 74044.89
93 22-Dec-15 73287.30 73380.14 72220.54 73102.10
94 21-Dec-15 72881.60 73781.35 72879.55 73328.16
95 18-Dec-15 73524.39 73524.39 72203.09 72460.35
96 17-Dec-15 73495.44 74178.78 72823.45 73711.88
97 16-Dec-15 72029.84 72887.89 71397.03 72831.78
98 15-Dec-15 69844.79 72391.87 69693.28 72156.79
99 14-Dec-15 71004.80 71695.94 69190.95 69308.74
100 11-Dec-15 72497.47 72511.95 70280.34 70280.34
101 10-Dec-15 74354.40 75237.06 72012.65 72354.16
102 9-Dec-15 73345.03 74732.11 72948.46 74583.74
103 8-Dec-15 73773.29 74204.29 72954.62 73100.86
104 7-Dec-15 74398.98 74534.13 73354.74 73908.89
105 4-Dec-15 75810.32 75887.79 73370.84 74265.30
106 3-Dec-15 76665.25 77141.32 75392.35 75452.84
107 2-Dec-15 77348.46 77766.72 76246.26 76394.96
108 1-Dec-15 75474.29 76785.45 75474.29 76785.45
109 30-Nov-15 75793.19 76535.24 75097.07 75232.79
110 27-Nov-15 75426.32 76522.93 74824.00 75638.43
111 26-Nov-15 76624.54 76690.36 74992.98 74997.64
112 25-Nov-15 76570.12 76975.33 75520.73 76836.52
113 24-Nov-15 79868.80 80008.03 76095.76 76242.98
114 23-Nov-15 80652.61 80784.15 79744.79 79744.79
115 20-Nov-15 80397.56 81121.69 80384.51 80681.67
116 19-Nov-15 80860.34 81117.98 80185.70 80441.20
117 18-Nov-15 81064.00 81476.48 80336.11 80514.17
118 17-Nov-15 81325.66 81857.53 81152.85 81152.85
119 16-Nov-15 81580.64 81822.37 81018.67 81046.42
120 13-Nov-15 82126.93 82292.34 81624.84 81878.75
121 12-Nov-15 82217.35 82295.70 81426.17 82143.43
122 11-Nov-15 81484.50 82364.99 81484.50 81717.99
123 10-Nov-15 82311.31 82592.47 81174.10 81174.10
124 9-Nov-15 82000.37 82622.20 81757.19 82050.14
125 6-Nov-15 83201.42 83231.88 81718.47 81930.21
126 5-Nov-15 83234.86 83329.36 82546.74 82955.67
127 4-Nov-15 83284.70 83784.77 83284.70 83684.07
128 3-Nov-15 83857.05 83926.68 82853.22 82913.85
129 2-Nov-15 83653.72 84354.08 83229.46 83693.61
130 30-Oct-15 78230.28 79504.68 77585.44 79409.00
131 28-Oct-15 78633.89 78650.89 77999.78 78536.29
132 27-Oct-15 79206.19 79384.03 78094.91 78662.51
133 26-Oct-15 79995.27 80403.05 79219.64 79262.26
134 23-Oct-15 80892.37 81066.72 80091.17 80124.84
135 22-Oct-15 79842.74 80532.23 79842.74 80255.91
136 21-Oct-15 80395.79 80423.96 79284.41 79765.28
137 20-Oct-15 79810.15 80594.10 79678.11 80496.48
138 19-Oct-15 78845.95 79894.92 78845.95 79734.54
139 16-Oct-15 79614.92 79614.92 78483.55 78483.55
140 15-Oct-15 80012.83 80383.05 79263.26 79263.26
141 14-Oct-15 78388.89 79502.62 78317.59 79380.24
142 13-Oct-15 79342.90 79495.46 77889.50 78358.61
143 12-Oct-15 78547.45 79619.64 78547.45 79300.09
144 9-Oct-15 79237.10 79616.10 78842.36 79214.93
145 8-Oct-15 78309.44 79245.68 78013.35 78661.03
146 7-Oct-15 77822.39 78726.61 77632.84 78698.17
147 6-Oct-15 76977.32 77606.67 76625.12 77258.59
148 5-Oct-15 75312.53 76902.54 75312.53 76902.54
149 2-Oct-15 74570.70 74691.20 73826.02 74396.65
150 1-Oct-15 74623.07 74835.80 74020.55 74530.96
151 30-Sep-15 74649.96 74752.94 73783.35 74205.47
152 29-Sep-15 72865.87 74327.49 72638.09 74257.65
153 28-Sep-15 74759.47 75128.26 73314.99 73314.99
154 23-Sep-15 74833.33 75070.20 74610.20 74610.20
155 22-Sep-15 76046.81 76189.52 74593.10 74993.71
156 21-Sep-15 74879.84 76028.31 74524.74 75860.70
157 18-Sep-15 74880.25 75102.09 74011.44 75099.03
158 17-Sep-15 74052.52 74980.56 73845.98 74980.56
159 16-Sep-15 73299.28 74378.49 73013.27 74149.46
160 15-Sep-15 71490.04 73196.09 71307.53 73173.35
161 14-Sep-15 71625.57 71682.49 71050.41 71299.43
162 11-Sep-15 71972.11 71993.94 71349.56 71350.87
163 10-Sep-15 71743.32 71954.44 71263.32 71846.52
164 9-Sep-15 72788.05 72895.52 71992.50 72003.34
165 8-Sep-15 72375.07 72628.86 71594.50 72051.79
166 7-Sep-15 72435.48 72435.48 71557.42 71865.82
167 4-Sep-15 73427.59 73997.88 72896.43 72950.11
168 3-Sep-15 74031.62 74397.64 73291.42 74004.13
169 2-Sep-15 73872.64 74260.70 73434.13 73656.12
170 1-Sep-15 74843.84 74899.14 73375.00 73569.66
171 31-Aug-15 74549.23 75320.70 74526.15 75210.37
172 28-Aug-15 74981.53 75156.94 74020.06 74641.60
173 27-Aug-15 74589.12 75157.89 74475.76 74813.48
174 26-Aug-15 73375.81 74140.94 72770.00 73615.91
175 25-Aug-15 72191.09 73778.35 71997.20 73509.71
176 24-Aug-15 72638.68 72638.68 69797.40 70465.82
177 21-Aug-15 74392.08 74623.33 73520.06 73797.77
178 20-Aug-15 75086.85 75086.85 73697.07 74681.84
179 19-Aug-15 76323.17 76646.78 75188.00 75299.59
180 18-Aug-15 76428.76 76894.55 75960.11 75960.11
181 17-Aug-15 77357.71 77569.71 76368.69 76922.44
182 14-Aug-15 76780.08 77699.27 76484.42 77308.95
183 13-Aug-15 78234.85 78234.85 75802.30 77085.50
184 12-Aug-15 78887.36 79062.94 78085.44 78174.81
185 11-Aug-15 78516.85 79908.65 78516.85 79719.99
186 10-Aug-15 78592.00 78759.44 77309.97 77495.29
187 7-Aug-15 79003.54 79123.64 78173.79 78427.06
188 6-Aug-15 78416.07 79030.09 78325.49 78803.08
189 5-Aug-15 78095.07 78562.43 77714.37 78134.32
190 4-Aug-15 78463.47 78753.82 77805.61 78234.86
191 3-Aug-15 79879.67 79879.67 78022.70 78164.09
192 31-Jul-15 78518.73 79909.68 78125.75 79909.68
193 30-Jul-15 77633.03 78889.41 77534.29 78271.49
194 29-Jul-15 78140.69 78635.12 77667.29 78079.76
195 28-Jul-15 77687.15 78729.32 77687.15 78024.02
196 27-Jul-15 78724.77 79171.13 77230.10 77351.98
197 24-Jul-15 78151.53 79256.36 77726.17 78712.07
198 23-Jul-15 81201.91 81201.91 78164.14 78336.57
199 22-Jul-15 81736.74 81856.73 80677.01 81222.38
200 21-Jul-15 81688.73 81888.14 80960.94 81583.62
201 20-Jul-15 82813.58 82894.50 81014.45 81319.97
202 16-Jul-15 82894.66 82999.12 82704.93 82789.78
203 15-Jul-15 83265.84 83523.10 82488.30 82727.86
204 14-Jul-15 83733.21 84192.88 82829.05 83041.13
205 13-Jul-15 82809.82 83678.48 82529.57 83388.32
206 10-Jul-15 82922.55 83396.33 82565.88 82791.85
207 9-Jul-15 80918.02 82332.69 80918.02 82286.34
208 8-Jul-15 81488.74 81488.74 80238.70 80386.59
209 7-Jul-15 82657.24 82860.57 81572.27 81572.27
210 6-Jul-15 80988.06 82447.63 80988.06 82365.85
211 3-Jul-15 82008.13 82165.91 81216.98 81216.98
212 2-Jul-15 81593.78 82007.73 80978.33 81879.96
213 1-Jul-15 82445.33 82939.86 81681.71 81681.71
214 30-Jun-15 81936.86 82415.57 81484.79 82249.53
215 29-Jun-15 82356.58 82723.89 81756.19 81756.19
216 26-Jun-15 83216.74 83868.26 83075.83 83546.06
217 25-Jun-15 84212.71 84529.26 83240.86 83277.09
218 24-Jun-15 83228.65 84266.35 83118.20 84140.65
219 23-Jun-15 83604.20 83863.57 82678.83 83068.46
220 22-Jun-15 82913.98 83759.94 82913.98 83426.18
221 19-Jun-15 81959.25 82781.34 81707.58 82454.38
222 18-Jun-15 81604.84 82235.61 81338.18 81932.45
223 17-Jun-15 80411.30 80917.47 80271.81 80713.26
224 16-Jun-15 79226.90 80521.07 79226.90 80183.75
225 15-Jun-15 80547.55 80748.23 78951.38 78951.38
226 12-Jun-15 80848.27 81170.24 80315.27 80532.51
227 11-Jun-15 79985.54 80924.87 79368.22 80845.24
228 10-Jun-15 78657.24 80007.76 78657.24 79747.89
229 9-Jun-15 78410.98 78786.83 77756.16 78146.25
230 8-Jun-15 75268.15 77805.41 75268.15 77805.41
231 5-Jun-15 82113.63 82972.87 81623.00 81943.42
232 4-Jun-15 82836.68 82905.87 81704.32 82499.02
233 3-Jun-15 81576.74 83411.64 81208.96 83393.57
234 2-Jun-15 80745.27 81480.90 80513.78 81420.24
235 1-Jun-15 82769.03 82785.05 80341.48 80429.08
236 29-May-15 83631.97 84697.26 82586.27 82981.15
237 28-May-15 84335.95 84500.67 83569.62 83569.62
238 27-May-15 83984.04 84292.05 82853.26 84292.05
239 26-May-15 84124.51 84852.09 83649.42 83649.42
240 25-May-15 85705.37 85788.10 84479.61 84567.03
241 22-May-15 86646.90 86711.55 85717.13 85803.92
242 21-May-15 87985.06 88513.69 86441.68 86565.03
243 20-May-15 88369.62 88509.74 87342.72 87791.06
244 18-May-15 87640.44 88651.88 87526.88 88651.88
245 15-May-15 87449.54 87995.74 87184.33 87604.89
246 14-May-15 86455.73 87651.31 86160.66 87243.66
247 13-May-15 85490.32 86562.92 85490.32 86417.48
248 12-May-15 84865.67 85399.49 84288.84 85363.47
249 11-May-15 84161.75 85236.53 84161.75 84752.83
250 8-May-15 82722.11 84269.73 82207.71 84059.89
251 7-May-15 82520.08 82798.69 81754.47 82588.73
252 6-May-15 83743.10 83743.10 82345.42 82441.37
253 5-May-15 83975.05 84605.65 83304.47 83380.67
254 4-May-15 83880.82 84305.28 83239.22 84018.92
我想将第一列转换为Date。我跑了这个:
strptime(df[,1], "%d-%b-%y","GMT")
但输出如下:
[1] NA NA NA NA NA NA
[7] NA NA NA NA NA NA
[13] NA NA NA NA NA NA
[19] NA NA NA "2016-03-31 GMT" "2016-03-30 GMT" "2016-03-29 GMT"
[25] "2016-03-28 GMT" "2016-03-25 GMT" "2016-03-24 GMT" "2016-03-23 GMT" "2016-03-22 GMT" "2016-03-21 GMT"
[31] "2016-03-18 GMT" "2016-03-17 GMT" "2016-03-16 GMT" "2016-03-15 GMT" "2016-03-14 GMT" "2016-03-11 GMT"
[37] "2016-03-10 GMT" "2016-03-09 GMT" "2016-03-08 GMT" "2016-03-07 GMT" "2016-03-04 GMT" "2016-03-03 GMT"
[43] "2016-03-02 GMT" "2016-03-01 GMT" NA NA NA NA
[49] NA NA NA NA NA NA
[55] NA NA NA NA NA NA
[61] NA NA NA NA NA NA
[67] NA NA NA NA NA NA
[73] NA NA NA NA NA NA
[79] NA NA NA NA NA NA
[85] NA NA NA NA NA NA
[91] NA NA NA NA NA NA
[97] NA NA NA NA NA NA
[103] NA NA NA NA NA NA
[109] NA NA NA NA NA NA
[115] NA NA NA NA NA NA
[121] NA NA NA NA NA NA
[127] NA NA NA NA NA NA
[133] NA NA NA NA NA NA
[139] NA NA NA NA NA NA
[145] NA NA NA NA NA NA
[151] NA NA NA NA NA NA
[157] NA NA NA NA NA NA
[163] NA NA NA NA NA NA
[169] NA NA NA NA NA NA
[175] NA NA NA NA NA NA
[181] NA NA NA NA NA NA
[187] NA NA NA NA NA NA
[193] NA NA NA NA NA NA
[199] NA NA NA NA NA NA
[205] NA NA NA NA NA NA
[211] NA NA NA NA NA NA
[217] NA NA NA NA NA NA
[223] NA NA NA NA NA NA
[229] NA NA NA NA NA NA
[235] NA "2015-05-29 GMT" "2015-05-28 GMT" "2015-05-27 GMT" "2015-05-26 GMT" "2015-05-25 GMT"
[241] "2015-05-22 GMT" "2015-05-21 GMT" "2015-05-20 GMT" "2015-05-18 GMT" "2015-05-15 GMT" "2015-05-14 GMT"
[247] "2015-05-13 GMT" "2015-05-12 GMT" "2015-05-11 GMT" "2015-05-08 GMT" "2015-05-07 GMT" "2015-05-06 GMT"
[253] "2015-05-05 GMT" "2015-05-04 GMT"
答案 0 :(得分:3)
转化strptime(x$Date,"%d-%b-%y")
对我来说很好。我强烈怀疑您有区域设置问题,因此March是区域设置中缩写与英文缩写(“Mar”)匹配的唯一月份。尝试Sys.getlocale()
(或sessionInfo()
)获取您的区域设置信息,
Sys.setlocale(locale="C")
strptime(x$Date,"%d-%b-%y")
将语言环境设置为 适用于此转化的通用值...
如果我是对的,那么这是duplicate,但我只有99%确定我是对的。