[R] Table to List Transformation Scenario

Phil Spector spector at stat.berkeley.edu
Wed Apr 21 20:39:48 CEST 2010


I'm guessing that you are using the words "table" and 
"list" to mean "data frame".  If that's the case, something
like this might get you started:

dfnew = reshape(Test1,varying=list(paste('Hour',1:23,sep='')),
                 timevar='Hour',idvar='Date',direction='long')
dfnew = dfnew[order(dfnew$Date,dfnew$Hour),]

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu


On Wed, 21 Apr 2010, Idgarad wrote:

> I have a series of tables, one for each environment indicating a date (row)
> and a sample at each hour of the day (0 to 23)
>
> Test1 Table:
> Date,Hour1,Hour2,...Hour23
> 1/1/10,123,123,...,123
>
> I would like to model this as a time series but how can I translate the
> table into a list such that I can get:
>
> 1/1/10 00:00, 123
> 1/1/10 01:00, 123
> 1/1/10 02:00, 123
> ...
> 1/1/10 23:00, 123
>
> Any suggestions on how to get that kind of translation done in R?
>
> Idgarad
> -- 
> "Who is John Galt?"
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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