[R] Importing Time Series Data for an R Beginner

Clay Heaton ccheaton at gmail.com
Thu Mar 11 21:13:24 CET 2010

Hi, I'm trying to learn R for a project I'm working on. I know several programming languages, so I'm comfortable with the syntax. What I can't figure out is how to import the file of time series data that I have and parse it into individual series.  The data was given to me in Excel, but I can output it to tab-delimited or csv. I've been able to pull in the entire table with read.table(), but I can't figure out how to parse it into distinct groups.

It looks like this:

Subject     Date    Time   Value
1     7/23/03  13:05:00   84
1     7/23/03  13:10:00   87
1     7/23/03  13:15:00   95
1     9/25/04  14:34:00   95
1     9/25/04  14:39:00   81
1     9/25/04  14:44:00   93
2     3/02/04  16:34:00   72
2     3/02/04  16:39:00   67
2     3/02/04  16:44:00   83
2     3/21/05  11:15:00   121
2     3/21/05  11:20:00   125
2     3/21/05  11:25:00   120

There are ~ 100,000 rows of data. There are 86 subjects and each of them have multiple traces. For each trace, the times are in uniform increments of 5 minutes. Some subjects have multiple traces, some have a single trace. Some traces include up to 500 values and others only 40.

For now, what I'm looking to do is to be able to generate summary statistics for each trace, and then for each subject. Hence, I need a way to aggregate by value or subject, where the criteria for aggregating traces are that the values were collected on the same day and all are within 5 minutes of each other. I would like to be able to iterate through the data to plot each trace independently.

Any suggestions to help me get started would be appreciated. I'm looking to learn, so I'd appreciate pointers to good tutorials or code examples of dealing with time series data.


More information about the R-help mailing list