I have a data frame with 22239 rows & 200 columns. The first column - NAME - is a character and the other columns are numeric. My goal is to operate on all elements of rows by:
- Finding the rows' median;
- Subtracting the median from the row element (value);
- Finding the rows` median absolute deviation (mad);
- Dividing rows elements by rows mad.
I tried this way
edata <- read.delim("a.txt", header=TRUE, sep="\t")
## Converting dataframe into Matrix
## Taking all rows but starting from 2 column to 200
data <- as.matrix(edata[,2:200]) 
for(i in 1:22239){  #rows below columns
    for(j in 1:200) {
        m <- median(data[i,]) # median of rows
        md <- mad(normdata[i,]) # mad of rows
        a <- data[i,j]  # assigning matrix element value to a
        subs = a-m    # substracting
        escore <- subs/md  # final score
        data[i,j] <- escore  # assigning final score to row elements
After getting new values for every elements of the rows I want to sort it according to the 75% quantiles on the basis of the NAME column. But, I am not sure how to do this.
I know my code isn't memory efficient. When I run the above code, the looping is very slow. Tried foreach, but couldn't succeed it. Can you guys suggest me the good way to deal with these kind of problems?
 
     
     
     
     
     
    