Hi All.

Apologies as I'm just getting to grips with R.

I have a set of genes and log fold changes.
As the genes have been converted from Affymetrix probes, and up to 11 probes represent one gene, I have a range of different log fold changes for each gene. I would like to take the average log fc for each gene when duplicated in the list.

I used the script below but as I'm a bit of a novice it isn't working too well and I get the error message stated at the bottom:

dat<-read.table("test.txt")
dim(dat)
dat[1:664,1:2]

Gene<-dat[,1]
fc<-dat[,2]

LogFC<-matrix(NA,664,1)
for(i in 1:664){
                for(j in 1:1){
                                LogFC[i]<-fc[i]
                                }
                }
fc[1:664,1]

####Take Average logfc of multiples of the same gene####
gid<-unique(Gene)
length(gid)
mGene<-matrix(NA,640,1)
mGene
for(i in 1:640){
                                rid<-which(Gene==gid[i])
                                for(j in 1:1){
                                                mGene[i]<-mean(fc[rid,j])
                                }
                }
####I get the error message "Error in fc[rid, j] : incorrect number of dimensions"

Any help would be much appriciated,

Many thanks everyone!

	[[alternative HTML version deleted]]

