# \donttest{
library(dplyr)
if (requireNamespace("DBI", quietly = TRUE) & requireNamespace("RSQLite", quietly = TRUE)) {
# connect DBMS
con_sqlite <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
# copy jobchange to the DBMS with a table named TB_JOBCHANGE
copy_to(con_sqlite, jobchange, name = "TB_JOBCHANGE", overwrite = TRUE)
# Using pipes ---------------------------------
# Diagnosis of all columns
con_sqlite %>%
tbl("TB_JOBCHANGE") %>%
diagnose() %>%
print()
# Positions values select columns, and In-memory mode and collect size is 200
con_sqlite %>%
tbl("TB_JOBCHANGE") %>%
diagnose(gender, education_level, company_size, in_database = FALSE, collect_size = 200) %>%
print()
# Using pipes & dplyr -------------------------
# Diagnosis of missing variables
con_sqlite %>%
tbl("TB_JOBCHANGE") %>%
diagnose() %>%
filter(missing_count > 0) %>%
print()
# Using pipes & dplyr -------------------------
# Diagnosis of missing variables
con_sqlite %>%
tbl("TB_JOBCHANGE") %>%
group_by(job_chnge) %>%
diagnose() %>%
print()
# Disconnect DBMS
DBI::dbDisconnect(con_sqlite)
} else {
cat("If you want to use this feature, you need to install the 'DBI' and 'RSQLite' package.\n")
}
# }
Run the code above in your browser using DataLab