read_xtabs | R Documentation |
These two functions facilitate reading in Excel spreadsheets of crosstabs generated from SPSS. Note that they're likely only useful for working with the DataHaven Community Wellbeing Survey.
read_xtabs(
path,
name_prefix = "x",
marker = "Nature of the [Ss]ample",
year = 2018,
process = FALSE,
verbose = TRUE,
...
)
read_weights(path, marker = "Nature of the [Ss]ample")
path |
Path to an excel file |
name_prefix |
String used to create column names such as x1, x2, x3, ..., Default: 'x' |
marker |
String/regex pattern used to demarcate crosstabs from weight
table. If |
year |
Numeric. As of now, its main purpose is to add an extra filtering step to take out headers in the 2015 files. Default: 2018 |
process |
Logical: if |
verbose |
Logical: if |
... |
Additional arguments passed on to |
A data frame. For read_xtabs
, there will be one column per
demographic/geographic group included, plus one for the questions & answers.
For read_weights
, only 2 columns, one for demographic groups and one for
their associated weights.
xtab2df()
if(interactive()) {
xt <- system.file("extdata/test_xtab2018.xlsx", package = "cwi")
read_weights(xt)
# returns a not-very-pretty data frame of the crosstabs to be processed
read_xtabs(xt)
# returns a pretty data frame ready for analysis
read_xtabs(xt, process = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.