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]]
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. >
Assuming the date as id is the first column followed by 23 values, try the read.reps function found here: http://www.mail-archive.com/r-help at r-project.org/msg92123.html like this: DF <- read.csv("myfile", as.is = TRUE) read.reps(DF, 23) On Wed, Apr 21, 2010 at 2:24 PM, Idgarad <idgarad at gmail.com> 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. >