# NOT RUN {
sample_char() # default
sample_char(n = 10)
sample_char(x_char = "abc", n = 10, replace = TRUE)
sample_char(x_char = c("x y", "6 9"), n = 6, replace = FALSE)
sample_char(x_char = c("x y", "6 9"), n = 20, replace = TRUE)
# Biased sampling:
sample_char(x_char = "abc", n = 20, replace = TRUE,
prob = c(3/6, 2/6, 1/6))
# Note: By default, n must not exceed nchar(x_char):
sample_char(n = 52, replace = FALSE) # works, but
# sample_char(n = 53, replace = FALSE) # would yield ERROR;
sample_char(n = 53, replace = TRUE) # works again.
# }
Run the code above in your browser using DataLab