Description Usage Arguments Details Value Note See Also Examples
View source: R/getProportionSingleVariable.R
Retrieves the proportion and confidence interval for a single variable in the YRBSS binary version, for a given location and a given year, as well as additional filters
1 2 | getProportionSingleVariable(.variable = NULL, .location = NULL,
.year = NULL, .filters = NULL, .level = 0.95)
|
.variable |
a string representing the name of the desired binary variable |
.location |
a string representing the desired location, defaults to "US" |
.year |
a int of the desired year (currently: 1991 to 2015) |
.filters |
a vector of strings representing desired filters (see details) |
.level |
the desired confidence interval level, defaults to 0.95 |
This function is a wrapper of the survey
package svyciprop
function to adequately return a proportion for a single binary variable with
confidence interval, from the YRBSS survey which contains complex weighted
sampling. You should NOT report proportions based on the raw data in
yrbss_data_binary
or yrbss_states_data_binary
.
a list containing:
prop |
the proportion of "Yes" for the desired variables within given filters |
ciLB |
Confidence Interval lower bound |
ciUB |
Confidence Interval upper bound |
n |
Sample size |
This function does basic input validity check-ups, e.g. if the .year
parameter entered makes sense or if the .location
is valid. It does NOT
however checks if for a given .variable
, for a given .year
and
possibly more filters there is enough (or at all) data to report a proportion.
If that isn't the case you should get a list of NA
s + a Warning.
yrbss_data_binary
, yrbss_states_data_binary
,
getListOfParticipatingStates
, yrbss_questions_binary
1 | getProportionSingleVariable("qn8", "US", 2015)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.