execute_cleaning_changes: Execute all loggged cleaning changes

Description Usage Arguments Value Examples

View source: R/execute.R

Description

Execute all loggged cleaning changes

Usage

1
2
execute_cleaning_changes(dir, datasetname = "parent.csv",
  logbookname = "cleaning_logbook.csv", uuid_column = NULL)

Arguments

dir

The directory name of the location where it needs to be saved.

datasetname

Name of the dataset. Needs to have a csv extention and be in the <dir> directory.

logbookname

Name of the logbook. Default is cleaning_logbook.csv. Needs to have a csv extention and be in the <dir> directory.

uuid_column

Name of the UUID column in the dataset. By default (if argument left empty) it will use grep to look for uuid in the column names but if there are no or multiple matches it will give an error.

Value

Nothing but the cleaned dataset will be saved as <datasetname>_cleaned.csv and the logbook will be overwritten with some comments in the <changed> column. TRUE if it is changed or an error if the question name could not be found.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
dir <- getwd()
extra_columns <- list(population_group = "population_group", governorate = "governorate_mcna")
## Not run: 
init_cleaning_log(dir, extra_columns = extra_columns)

data(mcna2019)
require(dplyr)
flag <- mcna2019$num_hh_member - mcna2019$num_family_member < 0
mcna2019[which(flag), c("num_hh_member", "num_family_member")]
uuid <- mcna2019$X_uuid[which(flag)]
log <- log_cleaning(mcna2019, uuid, action = "change",  extra_columns = extra_columns,
                    question.name = "num_hh_member",
                    issue="Number of family members should always be lower or equal
                    to household size, but for these it is not.",
                    new.value = mcna2019$num_family_member[which(flag)], dir = dir)
write.csv(mcna2019, "data.csv", row.names = F)
execute_cleaning_changes(dir, "data.csv", "cleaning_logbook.csv", uuid_column = "X_uuid")

## End(Not run)

boukepieter/dclogger documentation built on Feb. 7, 2020, 8:34 p.m.