R/rowPercent.R

Defines functions rowPercent

Documented in rowPercent

#'
#' @title Produces row percentages
#' @description this is an INTERNAL function.
#' @details The function is required required by the client function \code{ds.table2D}. 
#' @param dataframe a data frame
#' @keywords internal
#' @return a data frame
#' @author Gaye A
#' 
rowPercent <- function(dataframe){
  dt <- dataframe
  lastrow <- dim(dataframe)[1]
  lastcol <- dim(dataframe)[2]
  for(i in 1:lastrow){
    totalval <- dataframe[i, lastcol]
    dt[i,] <- round((dataframe[i,]/totalval)*100,2)      
  }
  return(dt)
}
datashield/dsBaseClient documentation built on May 16, 2023, 10:19 p.m.