Can someone verify if this R code for converting raw counts to TPM is correct?

    #' @title Compute TPM for a read count matrix
    #' @param dfr A numeric data.frame of read counts with samples (columns) and genes (rows).
    #' @param len A vector of gene cds length equal to number of rows of dfr.
    #' 
    r_tpm <- function(dfr,len)
    {
      dfr1 <- sweep(dfr,MARGIN=1,(len/10^4),`/`)
      scf <- colSums(dfr1)/(10^6)
      return(sweep(dfr1,2,scf,`/`))
    }
Use [this code snippet][1] from Michael Love.


  [1]: https://support.bioconductor.org/p/91218/#91256