pattern: Returns and updates pattern attribute.

Description

The pattern attribute contains information about the separator character used to name subquestions in the data. Survey software typically makes use of underscores to distinguish subquestions in a grid of questions, e.g. Q4_1, Q4_2, Q4_3, Q4_other. The function pattern returns the pattern attribute, and pattern<- updates the attribute.

Usage

1
2
3
  pattern(x)

  pattern(x) <- value

Arguments

x

surveydata object

value

New value

See Also

as.surveydata, which.q

Other Attribute functions: varlabels, varlabels<-

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Extract the pattern from membersurvey

oldptn <- pattern(membersurvey)
oldptn

# The pattern is used to extract columns

names(membersurvey)
grep("Q20", names(membersurvey), value=TRUE)

head(membersurvey["Q20"])
head(membersurvey["Q20_other"])

# Define a new pattern

pattern(membersurvey) <- list(sep="_", exclude="")
head(membersurvey["Q20"])

# Reset original pattern

pattern(membersurvey) <- oldptn
rm(oldptn)

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

All documentation is copyright its authors; we didn't write any of that.