[R] Simple matrix transformation question

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Apr 25 01:41:13 CEST 2012


library(reshape2)
?dcast
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Henry <hccoles at lbl.gov> wrote:

>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.
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list