R/clean_table.R

#' Cleans the table
#'
#' This function will clean the table by removing outliers.
#'
#' @param tab A data.table object containing the table you want to clean.
#' @return A data.table object with the results wanted.
#' @examples
#' tab_clean <- clean_table(tab)
#' @export

clean_table <- function(tab){
  examblanc <- dplyr::select(tab,contains("nb_examblanc_attempt"))
  userid <- tab$userid
  res <- apply(examblanc, MARGIN = 1, FUN = sum)
  table <- data.table(userid,res)
  retenus <- table[res <= 6]$userid
  tab <- tab[userid %in% retenus]
  
  doublons <- tab[, .N, by = userid][N > 1]$userid
  tab <- tab[!(userid %in% doublons)]
  tab <- tab[proportion_mooc_used <= 1]
  
  return(tab)
}
guillaumelf/BarchenPackage documentation built on May 31, 2019, 11:50 p.m.