Friday, June 21, 2013

Count frequency of factor column

Name: frqTable
Scenario: Want exchange data to Excel, or do the long tail fit

Code:
frqTable <- function(aFactorCol, aColName, aIsDecs="TRUE"){
  ret <- as.data.frame(table(aFactorCol))
  colnames(ret) <- c(aColName,'frq')
  ret <- ret[order(ret$frq,decreasing=aIsDecs),]
  rownames(ret) <- NULL
  return (ret);
}

No comments:

Post a Comment