Description Usage Arguments Value Examples

Suppose you have 3 different unique ballots and the amount of each ballot is 10, 20, 30. Now you want to create raw ballots as a list. Then you can use this function. See examples for usage.

1 |

`x` |
a list, each element of which should be a vector. Note:
only one of |

`n` |
how many times each element of |

`m` |
a matrix or dataframe, the number of rows should be equal to the length of n. |

`string` |
default is NULL. If it is not NULL, |

a list with replicated vectors, if `x`

is not NULL,
or a matrix/data.frame with duplicated rows, if
`m`

is not NULL.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# Use x and n
unique_ballot <- list(
c("A", "B", "C"), c("F", "A", "B"),
c("E", "D", "C", "B", "F", "A"), c("x","x", "A")
)
r <- c(1, 2, 3, 0)
y <- list2ballot(unique_ballot, r)
# Use string, x and n will be ignored.
# The characters can be written in a very loose way as follows,
# for the function will automatically delete unwanted parts.
# But do make sure there is no space or punctuation
# inside the names.
unique_ballot <- c(
"2, Bob, Mike Jane", "3: barack_obama;;Bob>Jane",
"0 Smith Jane", " 1 Mike???!!!"
)
y <- list2ballot(string = unique_ballot)
# Use a matrix.
m <- matrix(c(1, 2, 3, 3, 1, 2), nrow = 2, byrow = TRUE)
colnames(m) <- c("p1", "p2", "p3")
r <- c(3, 5)
y <- list2ballot(m = m, n = r)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.