[R] Multiplication of data frame with vector

cir p cirkus01 at yahoo.com
Tue Jul 7 10:05:09 CEST 2009


Dear group:
sorry for my beginners question, but I'm rather new to R and was searching high and low without success:

I have a data frame (df) with variables in the rows and observations in the columns like (the actual data frame has 15 columns and 1789 rows):

          early1 early2 early3 early4 early5
M386T1000  57056  55372  58012  55546  57309
M336T90    11063  10312  10674  10840  11208
M427T91    12064  11956  12692  12340  11924
M429T91     4594   3890   4096   4019   4204
M447T90    26553  27647  26889  26751  26929

Now I'm trying to transform each value column-wise to make columns to all have the same mean with:

df * mean(mean(df)) / mean(df).

I just can't get my head around this: mean(df) gives me the correct column means vector, and mean(mean(df)) gives me the correct total mean. The above operation works correctly for individual rows, i.e. if I do
 df[1,]*mean(mean(df))/mean(df)

Can someone tell me what I am doing wrong??
Thanks!




More information about the R-help mailing list