-
Notifications
You must be signed in to change notification settings - Fork 1
/
data_quality_softwaRRRe.R
60 lines (47 loc) · 1.86 KB
/
data_quality_softwaRRRe.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
## ---------------------------
## Script name: Mother of all functions, bringer of relief
## Purpose of script: to dominate file transformations
## Author: Alexandra Akaakar
## Date Created: 2024-04-06
##
## Copyright (c) Optimus_prime, 2024
## Email: [email protected]
##
## ---------------------------
##
## Notes:
##
##
## ---------------------------
#windows run comand for rstudio ts %localappdata%\RStudio
##--------------------------------------------------
#data_quality_report function
generate_reports <- function(dataframe, path) {
# Load necessary libraries
require(dlookr)
require(tidyverse) #need pipe
require(data.table)
require(dlookr)
require(dplyr)
# Assertion tests
if (!is.data.frame(dataframe)) {
stop("The provided data object is not a dataframe.")
}
# Check if the specified path exists, if not create it
if (!dir.exists(path)) {dir.create(path, recursive = TRUE)}
# Generating reports
all_diagnostic <- dlookr::diagnose(dataframe) %>% as.data.frame()
numeric_diagnostics <- dlookr::diagnose_numeric(dataframe) %>% as.data.frame()
categorical_diagnostics <- dlookr::diagnose_category(dataframe) %>% as.data.frame()
outlier_diagnostic <- dlookr::diagnose_outlier(dataframe) %>% as.data.frame()
report_list <- list(All_diagnostic = all_diagnostic,
Numeric_diagnostics = numeric_diagnostics,
Categorical_diagnostics = categorical_diagnostics,
Outlier_diagnostic = outlier_diagnostic)
# Save the diagnostics as CSV files in the specified path
for (name in names(report_list)) {
file_path <- file.path(path, paste0(name, "_", format(Sys.time(), '%d-%m-%Y_%H%M%S'), ".csv"))
write.csv(report_list[[name]], file_path, row.names = FALSE)
}
message("REPORTS SUCCESSFULLY OUTPUT")
}