#' @title Control all columns
#'
#' @description This function controls the type of all columns of a dataframe, raising warnings and providing tips if type seems irrelevant.
#'
#' @author Briac LE RAY (briac.leray@partnre.com)
#'
#' @return Does not return anything. Only raises warnings in the console.
#' @param df The dataframe to control. Type = dataframe
#' @keywords control type data
#' @examples control_type_data(df = my_dataframe)
control_type_data <- function(df) {
for (col in names(df)) {
type = typeof(df[[col]])
if(!type %in% c("double")) { # Test if date
if(detect_date(sample_n(df[col], 1000))) {
print(paste0("AVERTISSEMENT TYPE DE DONNEE: La colonne ", col, " semble ĂȘtre enrichie de dates, or son type est ", type, ". Exemple de valeur: ", dplyr::first(na.omit(df[[col]]))))
next
}
}
if(!type %in% c("double", "integer")) { # Test if date
if(detect_numeric(sample_n(df[col], 1000))) {
print(paste0("AVERTISSEMENT TYPE DE DONNEE: La colonne ", col, " semble ĂȘtre enrichie de nombres, or son type est ", type, ". Exemple de valeur: ", dplyr::first(na.omit(df[[col]]))))
next
}
}
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.