[R] time series from timed data

Sam Steingold sds at gnu.org
Fri Mar 18 19:19:29 CET 2011


Hi,
I have data with multiple sub-second entries:

2011/03/15 09:32:15.035619,-0.403103,1.09664,48.6,126.92,117.32
2011/03/15 09:32:15.069331,-0.39851,1.09874,48.6,126.92,117.32
2011/03/15 09:32:15.289135,-0.402463,1.10084,48.59,126.92,117.32
2011/03/15 09:32:15.296110,-0.450244,1.10063,48.59,126.92,117.32
2011/03/15 09:32:15.451358,-0.438813,1.10273,48.59,126.93,117.32
2011/03/15 09:32:15.476948,-0.428701,1.10482,48.6,126.93,117.32
2011/03/15 09:32:15.490478,-0.407603,1.10692,48.6,126.93,117.32
2011/03/15 09:32:15.592054,-0.396562,1.10901,48.6,126.93,117.32
2011/03/15 09:32:15.592054,-0.388935,1.11111,48.6,126.93,117.32
2011/03/15 09:32:15.910516,-0.372265,1.11321,48.6,126.93,117.32
2011/03/15 09:32:15.910681,-0.336162,1.1153,48.6,126.93,117.32
2011/03/15 09:32:16.684729,-0.335838,1.1174,48.6,126.93,117.32
2011/03/15 09:32:17.196003,-0.293883,1.1195,48.6,126.93,117.32
2011/03/15 09:32:17.271841,-0.322763,1.11925,48.6,126.93,117.32
2011/03/15 09:32:17.271841,-0.329827,1.12134,48.6,126.93,117.32
2011/03/15 09:32:17.271842,-0.35095,1.12343,48.6,126.93,117.32
2011/03/15 09:32:17.331044,-0.33095,1.12552,48.6,126.93,117.32
2011/03/15 09:32:18.793662,-0.34787,1.12762,48.605,126.96,117.33
2011/03/15 09:32:18.806576,-0.10088,1.12735,48.62,126.96,117.33
2011/03/15 09:32:18.915319,-0.0577731,1.12708,48.62,126.96,117.33
2011/03/15 09:32:18.915321,-0.0417141,1.12917,48.62,126.96,117.33
2011/03/15 09:32:19.766950,-0.0420244,1.13125,48.62,126.95,117.33
2011/03/15 09:32:20.143307,-0.0184469,1.13333,48.62,126.95,117.33

I can load it into a data.frame and convert the first column to POSIXt.
now I want to convert it to a multi-time series by replacing multiple
entries for each second with a single entry with mean value.
(plus one more column with the count).
e.g., the snippet above would turn into

2011/03/15 09:32:15,11,-0.4021,1.10545,48.6,126.926,117.32
2011/03/15 09:32:16,1,-0.335838,1.1174,48.6,126.93,117.32
2011/03/15 09:32:17,5,-0.3257,...
2011/03/15 09:32:18,4,...
2011/03/15 09:32:19,1,...
2011/03/15 09:32:20,1,...

how do I do that?

thanks!

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.5 (Final) X
http://palestinefacts.org http://openvotingconsortium.org
http://mideasttruth.com http://pmw.org.il http://www.memritv.org
Just because you're paranoid doesn't mean they AREN'T after you.



More information about the R-help mailing list