longString: Long String Max.

Description Usage Arguments Details Value See Also Examples

Description

longString returns the number of repeated values found sequentially within each row of a dataframe.

Usage

1
longString(x, na.rm = FALSE, return.value = FALSE)

Arguments

x

An R dataframe or matrix object.

na.rm

A logical scalar. Should missing values be removed? If TRUE, long string return will disregard missingness (e.g., c(2, 3, NA, 3) will return a long string value of 2, while FALSE would return 1.

return.value

A logical scalar. Should the value of the longest string be returned? If vector has no sequential repeats, this will return NA.

Details

This function is designed to work with a dataframe or matrix object, and has two primary methods of return: the number of the longest set of repetitions, or the value which those repititions utilised. For example, if a respondent used option A 10 times in a row, return.values = FALSE (default) would return 10, while return.values = TRUE would return "A".

Value

A vector of type integer, or type character if return.value = TRUE and input is a set of factors.

See Also

careless, malDist

Examples

1
2
3
4
5
6
7
## Not run: 
set.seed(77)
dat <- matrix(sample(1:3, 200, replace = TRUE),20,10)
longString(dat)
longString(dat, return.value = TRUE)

## End(Not run)

mattsigal/careless documentation built on May 21, 2019, 1:25 p.m.