This should work on your data using the 'reshape' package;


> nmr_19_model_aa<-read.table(url("
http://omega.psi.iastate.edu/data/nmr_19_model_aa.txt"),sep<http://omega.psi.iastate.edu/data/nmr_19_model_aa.txt%22),sep>
="")
> name.col<-c("pr","mod","mod_No","aa","aa_po","omega")
> colnames(nmr_19_model_aa)<-name.col
> attach(nmr_19_model_aa)

> nmr_19_model_aa.2<-data.frame
(pr=pr,model=paste(mod,mod_No,sep="_"),aa=paste(aa_po,aa,sep="_"),omega=omega)
> attach(nmr_19_model_aa.2)

> temp<-split(nmr_19_model_aa.2,nmr_19_model_aa.2$pr)
> class(temp)
[1] "list"
> names(temp)
 [1] "1A24" "1A57" "1A5J" "1A6X" "1AB7" "1AF8" "1AFI" "1AGG" "1AH9" "1AHL"
"1AJ3" "1AJW" "1AK7" "1ALG" "1AOY" "1APF" "1AUZ"
[18] "1AZJ" "1AZK"
> # show how to do it with one
> require(reshape)
[1] TRUE
> x.ans <- lapply(temp, function(.df){
+     x.r <- melt(.df)  # setup for 'casting'
+     x.c <- as.matrix(cast(x.r, aa ~ model))  # make a matrix
+     cbind(x.c, mean=apply(x.c, 1, mean), sd=apply(x.c, 1, sd))  # return
answer
+ })
> # show first element
> head(x.ans[[1]])
        MODEL_1 MODEL_10 MODEL_11 MODEL_12 MODEL_13 MODEL_14 MODEL_15
MODEL_16 MODEL_17 MODEL_18 MODEL_19 MODEL_2 MODEL_20
1_ALA     84.47    83.65    35.68    90.86     5.22    25.07    83.06
91.91    94.22    26.01    86.16   33.59    96.73
10_THR   112.37   111.48   107.58   115.86   111.25   115.27   112.66
115.42   107.43   108.04   116.90  116.78   122.04
100_GLN   78.52    66.41    71.85    86.28    67.72    84.80    74.74
89.17    86.58    72.23   100.27   89.84    84.64
101_THR   88.12    75.22    76.51    79.97    70.00    76.24    77.20
62.92    79.20    77.10    69.78   85.96    78.51
102_ILE  127.82   125.73   128.98   125.70   125.30   127.42   126.74
130.55   124.48   130.89   123.61  126.51   129.49
103_ARG   23.91    34.13    57.48    16.20    87.60    22.04    34.82
79.69    37.68    42.45    25.67   44.80    35.99
        MODEL_3 MODEL_4 MODEL_5 MODEL_6 MODEL_7 MODEL_8 MODEL_9
mean        sd
1_ALA     64.76   17.03   64.30   99.59   10.69   19.42   40.83  57.6625
33.499007
10_THR   110.82  115.20  111.98  119.53  104.27  112.14  110.21 112.8615
4.346347
100_GLN   78.79   90.64   71.63   81.45   65.87   69.15   63.74  78.7160
10.122561
101_THR   77.12   68.42   74.01   59.58   61.30   76.27   87.44  75.0435
7.909933
102_ILE  126.79  123.19  129.90  122.54  125.35  131.20  130.78 127.1485
2.715634
103_ARG   11.06    9.83   17.08   41.61   28.51   44.08   14.14  35.4385
20.886373

On 2/28/07, Aimin Yan <aiminy@iastate.edu> wrote:

> In order to make this question be clear, Here is my code
>
> >source("http://omega.psi.iastate.edu/data/nmr_19.R")
> > class(temp)
> [1] "list"
> > names(temp)
> [1] "1A24" "1A57" "1A5J" "1A6X" "1AB7" "1AF8" "1AFI" "1AGG" "1AH9" "1AHL"
> [11] "1AJ3" "1AJW" "1AK7" "1ALG" "1AOY" "1APF" "1AUZ" "1AZJ" "1AZK"
> > head(temp[[1]])
>     pr   model    aa  omega
> 1 1A24 MODEL_1 1_ALA  84.47
> 2 1A24 MODEL_1 2_GLN  63.06
> 3 1A24 MODEL_1 3_TYR 107.72
> 4 1A24 MODEL_1 4_GLU  54.36
> 5 1A24 MODEL_1 5_ASP  67.01
> 6 1A24 MODEL_1 6_GLY 999.00
>
> This Iist have 19 data.frame that has their name such as 1A24,1A57....
> The above is the structure for  data.frame 1A24, pr have 1 level,
> model has 20 levels,aa has 189 levels
>
> I want to get the following matrix for each data.frame in this list like
> this
>
> 1A24
>              MODEL_1 MODEL_2 .....     MODEL_20   Mean_of_20_models
> Sd_of_20_models
> 1_ALA    84.47
> 2_GLN    63.06
> 3_TYR    107.72
> 4_GLU    54.36
> 5_ASP
> 6_GLY
>
> same thing for other data.frame in this list
>
> 1A57
> .....
>
> 1A5J
> .....
>
> Means_of_20_models is average of omega for 1_ALA in 20 models
> Sd_of_20_models is standard deviation of omega for 1_ALA between 20 models
>
>
> Does anyone has some advice on how to do this?
>
> thanks
>
> Aimin
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

