longstring | R Documentation |
This function calculates the longstring value for a given vector of values.
longstring(x, tolerance = NULL)
x |
A vector of values for which the longstring value needs to be calculated. |
tolerance |
An optional parameter indicating the tolerance for considering consecutive values as equal (default is NULL). |
A dataframe containing the following information:
The longstring value(s) based on the most frequent value(s) or the unique value(s).
The length of the longest run of consecutive values.
The average length of non-NA runs of consecutive values (not computed when tolerance is used).
df <- data.frame(
rbind(
c(1, 1, 2, 2, 2, 3, 3, 3, 3),
c(1, 2, 3, 4, 4, 4, 4, 2, 6)
)
)
# Example 1: Without tolerance
longstring(df)
# Example 2: With tolerance
longstring(df, tolerance = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.