questions: Returns a list of all the unique questions in the surveydata...

Description Usage Arguments Value See Also Examples

View source: R/questions.R

Description

In many survey systems, subquestions take the form Q1_a, Q1_b, with the main question and subquestion separated by an underscore. This function conveniently returns all of the main questions in a surveydata() object. It does this by using the pattern() attribute of the surveydata object.

Usage

1
questions(x, ptn = pattern(x))

Arguments

x

Object to coerce to surveydata

ptn

A list with two elements, sep and exclude. See pattern() and which.q() for more detail.

Value

numeric vector

See Also

which.q

Other Question functions: qTextCommon, qTextUnique, qText, splitCommonUnique, which.q

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Basic operations on a surveydata object, illustrated with the example dataset membersurvey

class(membersurvey)

questions(membersurvey)

which.q(membersurvey, "Q1")
which.q(membersurvey, "Q3")
which.q(membersurvey, c("Q1", "Q3"))

qText(membersurvey, "Q3")
qTextUnique(membersurvey, "Q3")
qTextCommon(membersurvey, "Q3")

# Extracting columns from a surveydata object

head(membersurvey[, "Q1"])
head(membersurvey["Q1"])
head(membersurvey[, "Q3"])
head(membersurvey[, c("Q1", "Q3")])

# Note that the result is always a surveydata object, even if only one column is extracted

head(membersurvey[, "id"])
str(membersurvey[, "id"])

surveydata documentation built on July 20, 2017, 1:04 a.m.