Tidying up, transforming and exploring data is an important part of data analysis, and you can manage many common tasks in this process with the tidyverse or related packages. The sjmisc-package fits into this workflow, especially when you work with labelled data, because it offers functions for data transformation and labelled data utility functions. This vignette describes typical steps when beginning with data exploration.
The examples are based on data from the EUROFAMCARE project, a survey
on the situation of family carers of older people in Europe. The sample
data set efc is part of this package. Let us see how the
family carer’s gender and subjective perception of negative impact of
care as well as the cared-for person’s dependency are associated with
the family carer’s quality of life.
The first thing that may be of interest is probably the distribution
of gender. You can plot frequencies for labelled data with
frq(). This function requires either a vector or data frame
as input and prints the variable label as first line, followed by a
frequency-table with values, labels, counts and percentages of the
vector.
frq(efc$c161sex)
#> carer's gender (x) <numeric>
#> # total N=908 valid N=901 mean=1.76 sd=0.43
#>
#> Value | Label | N | Raw % | Valid % | Cum. %
#> -----------------------------------------------
#> 1 | Male | 215 | 23.68 | 23.86 | 23.86
#> 2 | Female | 686 | 75.55 | 76.14 | 100.00
#> <NA> | <NA> | 7 | 0.77 | <NA> | <NA>Next, let’s look at the distribution of gender by the cared-for
person’s dependency. To compute cross tables, you can use
flat_table(). It requires the data as first argument,
followed by any number of variable names.
But first, we need to know the name of the dependency-variable. This
is where find_var() comes into play. It searches for
variables in a data frame by
By default, it looks for variable name and labels. The function also
supports regex-patterns. By default, find_var() returns the
column-indices, but you can also print a small “summary”” with the
out-argument.
# find all variables with "dependency" in name or label
find_var(efc, "dependency", out = "table")
#> col.nr var.name var.label
#> 1 5 e42dep elder's dependencyVariable in column 5, named e42dep