longstring: Identifies the longest string of identical consecutive...

View source: R/longstring.R

longstringR Documentation

Identifies the longest string of identical consecutive responses for each observation

Description

Takes a matrix of item responses and, beginning with the second column (i.e., second item) compares each column with the previous one to check for matching responses. For each observation, the length of the maximum uninterrupted string of identical responses is returned. Additionally, can return the average length of uninterrupted string of identical responses.

Usage

longstring(x, avg = FALSE)

Arguments

x

a matrix of data (e.g. item responses)

avg

logical indicating whether to additionally return the average length of identical consecutive responses

Author(s)

Richard Yentes ryentes@gmail.com, Francisco Wilhelm franciscowilhelm@gmail.com

References

Johnson, J. A. (2005). Ascertaining the validity of individual protocols from web-based personality inventories. Journal of Research in Personality, 39, 103-129. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jrp.2004.09.009")}

Examples

careless_long <- longstring(careless_dataset, avg = FALSE)
careless_avg <- longstring(careless_dataset, avg = TRUE)
boxplot(careless_avg$longstr) #produce a boxplot of the longstring index
boxplot(careless_avg$avgstr)

careless documentation built on Oct. 1, 2023, 9:06 a.m.