This function checks whether one set of variables is consistent within values of another set of variables. If they are, returns TRUE. If they aren't, it will return a list of data frames, one for each element of .var, consisting only of the observations and variables in which there are inconsistencies.

fixed_check(.df, .var = NULL, .within = NULL)

Arguments

.df

Data frame, pibble, or tibble.

.var

Quoted or unquoted variable(s) in .df that are to be checked for consistency. If not specified, uses all variables in .df that are not in .within.

.within

Quotes or unquoted variable(s) that the .var variables should be consistent within.

Examples

# In the Scorecard data, it should be the case that # state_abbr and inst_name never change within university. # Let's see if that's true data(Scorecard) fixed_check(Scorecard, .var = c(state_abbr, inst_name), .within = unitid)
#> [1] TRUE
# it returns TRUE! We're good to go # count_not_working has no reason to be constant within unitid, # but let's see what happens if we run it through fixed_check(Scorecard, .var = count_not_working, .within = unitid)
#> $count_not_working #> # A tibble: 45,517 x 9 #> unitid inst_name state_abbr pred_degree_awa~ year earnings_med #> <int> <chr> <chr> <int> <int> <int> #> 1 149028 Saint An~ IL 3 2007 NA #> 2 189811 St Paul'~ NY 2 2007 84600 #> 3 215479 Joseph F~ PA 1 2007 NA #> 4 215965 Heritage~ PA 1 2007 NA #> 5 232618 Centra C~ VA 2 2007 54200 #> 6 232724 Danville~ VA 2 2007 NA #> 7 149028 Saint An~ IL 3 2009 NA #> 8 200244 Sanford ~ ND 3 2009 56400 #> 9 210456 Abington~ PA 1 2009 NA #> 10 113537 Dell'Art~ CA 1 2011 NA #> # ... with 45,507 more rows, and 3 more variables: count_not_working <int>, #> # count_working <int>, repay_rate <dbl> #>
# It gives back a tibble with inconsistent obs!