Description Usage Arguments Value Note See Also Examples
An internal function to that tells collapse whether to collapse with the category to the left or to the right, depending on which adjacent category is smaller, or based on user preference in case of a tie.
1 | merge_right_or_left(v, i, prefer = c("left", "right"))
|
v |
A vector of response categories. |
i |
An index based on a table of sorted (ascending) response categories of v. i must range from 1 to the maximum number of response categories. For example, for response categories 1, 2, 3, 4, and 5, i can be 1, 2, 3, 4, or 5. |
prefer |
A user supplies preference of whether to merge left or right in the case of a tie (i.e., equal response counts at i - 1 and i + 1. |
"left" or "right"; this tells collapse which direction to merge to.
This is intended as an internal function to the collapse() function. Use with care for other purposes.
collapse()
merge_w_left()
merge_w_right()
1 2 3 4 5 6 7 8 | ## Not run:
sparse_vector <- c(1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5)
merge_right_or_left(sparse_vector, 2, "left")
merge_right_or_left(sparse_vector, 2, "right")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.