# [R] How to simplify

From: Rhett Eckstein <glaxowell_at_gmail.com>
Date: Thu 08 Dec 2005 - 01:38:56 EST

Dear list,
I have a list containing parameters (time and X1), and have "n" similar data set like
the following:
> cal

[]
time X1

```1  0.0 10.006306
2  0.5  9.433443
3  1.0  8.893405
4  2.0  7.904274
5  4.0  6.243807
6  6.0  4.932158
7  8.0  3.896049
8 10.0  3.077604

[]
time        X1
1  0.0 10.015972
2  0.5  9.460064
3  1.0  8.935039
4  2.0  7.970755
5  4.0  6.343151
6  6.0  5.047900
```

7 8.0 4.017131
8 10.0 3.196856

[]
time X1

```1  0.0 9.985741
2  0.5 9.552583
3  1.0 9.138239
4  2.0 8.362664
5  4.0 7.003394
6  6.0 5.865057
7  8.0 4.911747
8 10.0 4.113382

```

[]
.......

[[n]]
.......

And I would like to put all X1( when time=0) together, time=0.5,1... are the same.
then calculate the mean value.
> a<-list()
> b<-list()
> c<-list()
> d<-list()
> e<-list()

.......
> for(i in 1:n){

```+   a[[i]]<-cal[[i]][1,2]
+   b[[i]]<-cal[[i]][2,2]
+   c[[i]]<-cal[[i]][3,2]
+   d[[i]]<-cal[[i]][4,2]
+   e[[i]]<-cal[[i]][5,2]
+   .........
```

}
>mean.a<-(a[]+a[]+a[]+.....)/n
>mean.b<-(b[]+b[]+b[]+.....)/n
>mean.c<-(c[]+c[]+c[]+.....)/n
>mean.d<-(d[]+d[]+d[]+.....)/n
>.............
>xy<-c(mean.a,mean.b,mean.c,mean.d,........)
But the way I use seem not very smart.
So please give me some hints to the simplify this. Thanks in advance !!
Sincerely!!

R-help@stat.math.ethz.ch mailing list