read_xtabs | R Documentation |
Deprecation notice: Crosstab-related
functions have been moved from cwi to the dcws package. The versions here will be
removed soon. 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 = NULL,
process = FALSE,
verbose = TRUE,
...
)
read_weights(path, year, 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: year of the survey (or end year, in the case of pooled data).
This tells the functions how to read the files, since formatting has changed
across years of the survey. Because the ability to read a file depends so much
on the year for which it was produced, this argument no longer defaults to a
specific year. Instead, if |
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.
dcws::read_xtabs()
dcws::xtab2df()
Other dcws-migration:
collapse_n_wt()
,
cws_demo
,
sub_nonanswers()
,
xtab2df()
## Not run:
# these functions are being deprecated
# replace them with their equivalents in the dcws package
xt <- system.file("extdata/test_xtab2018.xlsx", package = "dcws")
dcws::read_weights(xt, year = 2018)
# returns a not-very-pretty data frame of the crosstabs to be processed
dcws::read_xtabs(xt, year = 2018)
# returns a pretty data frame ready for analysis
dcws::read_xtabs(xt, year = 2018, process = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.