need some help figuring out how to make a loop in R.
I have a data frame named x x dimensions are 12773 rows and 86 columns.
column 1 has gene name, columns 2-85 counts for my different libraries, and 86 column is the mean of the library counts in columns 2-85 for each gene name.
I need help making a loop that would create a data frame or matrix output with the values of residuals of mean:
count - mean for each library and gene.
Expected output would be a new data frame y with column 1 gene names from data frame x which is column 1. In addition to having columns 2-85 with values that correspond to count-mean
Data frame x:
gene accepted_hits_x1.bam accepted_hits_x2.bam ... mean
AARS2 12 6 6
DATA FRAME: y
gene accepted_hits_x1.bam accepted_hits_x1.bam .... 1 AARS1 -6 0