pattern | R Documentation |
The pattern attribute contains information about the separator character used to name sub-questions in the data. Survey software typically makes use of underscores to distinguish sub-questions 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.
pattern(x)
pattern(x) <- value
x |
surveydata object |
value |
New value |
as.surveydata()
, which.q()
Other Attribute functions:
varlabels()
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.