I have a data set of previous 3 month average stock returns of 200 firms for 92 months. Months are in rows and firms are in columns. Now i have to calculate mean of the top 20 percent of firms given that the values are non-zero. Following is the code:
mmt1<-mean(as.numeric(comb[1,1:40]))
I need to know how to exclude zero values from mean calculation.