How to deal with duplicate genes having different expression values? I have RNA-Seq data which is FPKM. In the dataframe df first column is gene_name and the other 100 columns are samples.

Usually if it is counts data I do like following:

df2 &lt;- aggregate(. ~ gene_name, data = df, max)


I'm not sure what do with the FPKM data if there are duplicate genes with different FPKM value for the same sample.

Lets say it looks like this:

gene_name     sample1        sample2        sample3
5S_rRNA      0.3206147    0.3327312      0.377578
5S_rRNA      0.3342000    0.0000000      0.1305166


Any suggestions please.
I assume you're familiar with the various issues surrounding FPKMs, so I'll not expound upon them.

As a general rule, you should be using gene IDs rather than gene names, since the former are unique while the latter are not. If you only have access to data quantified on gene names, then the appropriate way to merge RPKMs is with a weighted sum:

$FPKM_{gene} = \frac{FPKM_{copy1} * Length_{copy1} + FPKM_{copy2} * Length_{copy2}}{Length_{copy1} + Length_{copy2}}$

As an aside, rRNA expression levels will tend to be wrong, since they're normally excluded by either poly-A enrichment or the use of ribo-zero.