Description Usage Arguments Details Value See Also Examples
These functions are designed for working with piping operator %>%
from 'magrittr' package.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
... |
Comma separated list of unquoted variable names. You can use special
functions such as 'starts_with', 'ends_with', 'contains' and etc. For details see
|
no_dup |
Logical. Should we check for absence of duplicated values in each row? |
show |
Additional variables (such as 'id') that should be shown with report about errors. |
.dots |
Use mult_()/sngl_() to do standard evaluation. See vignette("nse") in dplyr package for details |
.data |
data.frame |
Supposed usage is: checked_data.frame %>% mult(var_names)(valid_values,exclusive)
or checked_data.frame %>% mult(var_names)(valid_values)
Only valid values should be exists in var_names. All other values will be considered
incorrect. For multiple response questions (mult
) it is only necessary
that each row will have at least one valid non-NA values.
If any of exclusive values exists in row all other values should be NA .
mult
function checks multiple response questions only with categorical coding.
For checking multiple response questions with dichotomous coding see dmult
.
If 'values' is missing than all values considered valid except NA.
Only first error in the row is reported. If there are other errors for
this case they will be reported only after correction of first error.
mult
/sngl
functions returns another function
value(.data,...,exclusive). That function accepts data.frame and valid values.
See examples. 'value' function return data.frame with attribute with
results of checking.
report
print results of checking and invisibly returns checked data.frame.
check_internal
, select
,
%>%
, dmult
, error_if
,
move
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 | library(dplyr)
data(ProductTestRaw)
## Example 1 ##
# 4 errors: 2 missing, 2 invalid codes
ProductTestRaw %>%
sngl(s2b)(2:3) %>%
report
## Example 2 ##
data(codeframe)
valid_a1 = make_labels(codeframe$likes)
# Exclusive values
# 1 Liked everything
# 2 Disliked everything
# 99 Hard to say
# 5 errors: 1 missing value, 1 invalid code, 1 code duplication,
# 2 non-exclusive values.
# Additional variable 'id' also is shown.
ProductTestRaw %>%
mult(a1_1:a1_6,show = id)(valid_a1,exclusive=c(1,2,99)) %>%
report
## Example 3 ##
valid_a4 = make_labels(codeframe$dislikes_in_appearance)
# question a4 was asked only if codes 1-4 marked in a3
# 3 errors: 1 missing value, 1 invalid code, 1 code in case of a3 in 5-7.
ProductTestRaw %>%
check_if(a3 %in% 1:4) %>%
mult(a4_1:a4_6)(valid_a4,exclusive=99) %>%
report
## Example 4 ##
# Usage in programming (e. g. in cycle 'for')
checked_vars = c("a3","a22","b3","b23")
# there is one error in a22
for (each_var in checked_vars){
ProductTestRaw %>%
sngl_(each_var)(1:7) %>%
report
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.