[R] Simple matrix transformation question

Henry hccoles at lbl.gov
Wed Apr 25 00:34:56 CEST 2012


I know this is likely very simple.  I want to change a matrix that was given
to me not sorted by timestamp to sorted by timestamp.   It was sorted by
CRAH_Name.  There are 264k records initially.  The CRAH names start at 11
and go to 98 but there are a number of missing values (CRAH_Name), total
approx. 50.

A small example of the given matrix

Time_Stamp	Power	CRAH_Name
4/16/2012 00:00	3.4862	11
4/16/2012 00:01	3.4862	11
4/16/2012 00:02	3.61035	11
4/16/2012 00:03	3.57215	11
4/16/2012 00:04	3.6008	11
4/16/2012 00:05	3.64855	11
4/16/2012 00:06	3.64855	11
4/16/2012 00:07	3.6008	11
4/16/2012 00:08	3.639	11
4/16/2012 00:09	3.6581	11
4/16/2012 00:10	3.6963	11
4/16/2012 00:00	2.618646	98   (timestamping starts over again at 00:00)
4/16/2012 00:01	2.195102	98
4/16/2012 00:02	2.758223	98
4/16/2012 00:03	2.796727	98
4/16/2012 00:04	2.652337	98
4/16/2012 00:05	2.233606	98
4/16/2012 00:06	2.811166	98
4/16/2012 00:07	2.690841	98
4/16/2012 00:08	2.406874	98
4/16/2012 00:09	2.811166	98
4/16/2012 00:10	2.286549	98

I want to transform into a dataframe that looks like this..
CRAH Name             11                       12                    
13............                    98
timestamp ..01        power value   power value  power value
...........power value
timestamp ..02        power value   power value  power value
...........power value
timestamp ..03        power value   power value  power value
...........power value

This is how I'm used to dealing with time series data.

Thanks very much for any help.  I would like to use standard R function if
not too complicated.




--
View this message in context: http://r.789695.n4.nabble.com/Simple-matrix-transformation-question-tp4585044p4585044.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list