You can store individual time series in a list, say l
, and set dim
attribute on it. You can set dimnames
(i.e. row names and column names) too. With that you can use it almost as if it is a matrix/data.frame
# Generate length 15 vectors for 10 subjects
l <- replicate(10, list(rnorm(15)))
dim(l) <- c(5, 2)
dimnames(l) <- list(subject=1:5, variable=c("a", "b"))
l
## variable
## subject a b
## 1 Numeric,15 Numeric,15
## 2 Numeric,15 Numeric,15
## 3 Numeric,15 Numeric,15
## 4 Numeric,15 Numeric,15
## 5 Numeric,15 Numeric,15
Now you can:
l[[1,1]] # time series for subject 1, var 1
## [1] -0.02425 0.88986 0.36260 -1.78774 -1.48874 -1.46750 0.38329
## [8] 0.18573 -1.65675 0.59374 0.81669 1.06867 -1.71847 0.81889
## [15] 0.10796
or
l[[2, "b"]] # time series for subject 2, var "b"
## [1] 0.45616 -0.67563 -1.42116 -0.42621 0.51648 0.35147 0.68243
## [8] 1.17581 -0.16696 0.77492 -1.76446 1.50580 0.06075 0.37734
## [15] -0.92797
etc...