drop_empty_rows | R Documentation |
By default tables produced by functions tables, cross_cpct,
cross_fun and cross_fun_df are created with all
possible value labels. If values for this labels are absent in variable there
are NA's in rows and columns.
drop_empty_rows
/drop_empty_columns
are intended to remove
these empty rows/columns. drop_r
and drop_c
are the same
functions with shorter names. drop_rc
drops rows and columns
simultaneously.
drop_empty_rows(x, excluded_rows = NULL, excluded_columns = NULL)
drop_empty_columns(x, excluded_rows = NULL, excluded_columns = NULL)
drop_r(x, excluded_rows = NULL, excluded_columns = NULL)
drop_c(x, excluded_rows = NULL, excluded_columns = NULL)
drop_rc(x)
x |
data.frame/etable(result of cro and etc.) |
excluded_rows |
character/logical/numeric rows which won't be dropped
and in which NAs won't be counted. If it is characters then they will be
considered as pattern/vector of patterns. Patterns will be matched with
Perl-style regular expression with values in the first column of |
excluded_columns |
logical/numeric/characters columns which won't be dropped and in which NAs won't be counted. By default for class 'etable' it is first column - column with labels in table. |
data.frame with removed rows/columns
data(mtcars)
mtcars = apply_labels(mtcars,
vs = "Engine",
vs = num_lab("
0 V-engine
1 Straight engine
9 Other
"),
am = "Transmission",
am = num_lab("
0 Automatic
1 Manual
9 Other
")
)
with_empty = cross_cases(mtcars, am, vs)
drop_empty_rows(with_empty)
drop_empty_columns(with_empty)
drop_rc(with_empty)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.