diagnose.tbl_dbi: Diagnose data quality of variables in the DBMS

Description Usage Arguments Details Value Diagnostic information See Also Examples

Description

The diagnose() produces information for diagnosing the quality of the column of the DBMS table through tbl_dbi.

Usage

1
2
## S3 method for class 'tbl_dbi'
diagnose(.data, ..., in_database = TRUE, collect_size = Inf)

Arguments

.data

a tbl_dbi.

...

one or more unquoted expressions separated by commas. You can treat variable names like they are positions. Positive values select variables; negative values to drop variables. If the first expression is negative, diagnose() will automatically start with all variables. These arguments are automatically quoted and evaluated in a context where column names represent column positions. They support unquoting and splicing.

in_database

a logical. Specifies whether to perform in-database operations. If TRUE, most operations are performed in the DBMS. if FALSE, table data is taken in R and operated in-memory.

collect_size

a integer. The number of data samples from the DBMS to R. Applies only if in_database = FALSE.

Details

The scope of data quality diagnosis is information on missing values and unique value information. Data quality diagnosis can determine variables that require missing value processing. Also, the unique value information can determine the variable to be removed from the data analysis.

Value

An object of tbl_df.

Diagnostic information

The information derived from the data diagnosis is as follows.:

See vignette("diagonosis") for an introduction to these concepts.

See Also

diagnose.data.frame, diagnose_category.tbl_dbi, diagnose_numeric.tbl_dbi.

Examples

 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
library(dplyr)

# 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()
  
# Positive values select columns
con_sqlite %>% 
  tbl("TB_JOBCHANGE") %>% 
  diagnose(gender, education_level, company_size)
  
# Negative values to drop columns
con_sqlite %>% 
  tbl("TB_JOBCHANGE") %>% 
  diagnose(-gender, -education_level, -company_size)
  
# Positions values select columns, and In-memory mode
con_sqlite %>% 
  tbl("TB_JOBCHANGE") %>% 
  diagnose(1, 3, 8, in_database = FALSE)
  
# Positions values select columns, and In-memory mode and collect size is 200
con_sqlite %>% 
  tbl("TB_JOBCHANGE") %>% 
  diagnose(-8, -9, -10, in_database = FALSE, collect_size = 200)

# Using pipes & dplyr -------------------------
# Diagnosis of missing variables
con_sqlite %>% 
  tbl("TB_JOBCHANGE") %>% 
  diagnose() %>%
  filter(missing_count > 0)
  
# Disconnect DBMS   
DBI::dbDisconnect(con_sqlite)
  

bit2r/kodlookr documentation built on Dec. 19, 2021, 9:49 a.m.