Informatively display a maximum number of elements
plu_more(x, max = 5, type = TRUE, fn = NULL, ..., det = "more") more(x, max = 5, type = TRUE, fn = NULL, ..., det = "more")
x  A vector or list. 

max  The maximum number of items to list.
Additional arguments are replaced with "n more".
Defaults to 
type 

fn  A function to apply to the number of additional elements.
Default to 
...  Additional arguments to 
det  A determiner to place before the number of additional elements. Defaults to "more". 
If x
is a vector, a character vector with a length of max
+ 1
or less.
If x
is a list, a list with max + 1
or fewer elements.
plu::more(letters)#> [1] "a" "b" "c" #> [4] "d" "e" "21 more characters"# Setting `max` plu::more(letters, max = 10)#> [1] "a" "b" "c" #> [4] "d" "e" "f" #> [7] "g" "h" "i" #> [10] "j" "16 more characters"plu::more(letters, max = 27)#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" #> [20] "t" "u" "v" "w" "x" "y" "z"# If `max` is Inf or NULL, all elements will be preserved plu::more(letters, max = Inf)#> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" #> [20] "t" "u" "v" "w" "x" "y" "z"# If `max` is less than one, no elements will be preserved plu::more(letters, max = 0)#> [1] "26 characters"# Setting element type plu::more(letters, type = "letter")#> [1] "a" "b" "c" "d" #> [5] "e" "21 more letters"# If `type` is FALSE or NULL, no type will be included plu::more(letters, type = FALSE)#> [1] "a" "b" "c" "d" "e" "21 more"# Automatically generating type plu::more(1:100)#> [1] "1" "2" "3" "4" #> [5] "5" "95 more integers"#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] 3 #> #> [[4]] #> [1] 4 #> #> [[5]] #> [1] 5 #> #> [[6]] #> [1] "95 more integers" #>#> [[1]] #> [1] 1 #> #> [[2]] #> [1] 2 #> #> [[3]] #> [1] "a" #> #> [[4]] #> [1] "b" #> #> [[5]] #> [1] "c" #> #> [[6]] #> [1] "23 more elements" #>#> [1] "1/9" "1/4" "3/7" #> [4] "2/3" "1/1" "4 more characters"# Setting a determiner other than "more" plu::more(letters, det = "other")#> [1] "a" "b" "c" #> [4] "d" "e" "21 other characters"#> [1] "a, b, c, d, e and 21 more characters"#> [1] "a" "b" #> [3] "c" "d" #> [5] "e" "twentyone more characters"#># Automatic pluralization of type fish < c("sea bass", "crucian carp", "dace", "coelecanth") plu::more(fish, max = 3, type = "fish")#> [1] "sea bass" "crucian carp" "dace" "1 more fish"plu::more(fish, max = 2, type = "fish")#> [1] "sea bass" "crucian carp" "2 more fish"#> [1] "incisor" "canine" "molar" "1 more tooth"plu::more(teeth, max = 2, type = "tooth")#> [1] "incisor" "canine" "2 more teeth"#> [1] "saguaro" "prickly pear" "barrel" "1 more cactus"plu::more(cacti, max = 2, type = "cactus")#> [1] "saguaro" "prickly pear" "2 more cacti"# Using plu_more() within a function verbose_sqrt < function(x) { if (any(x < 0)) { problems < x[x < 0] prob_msg < crayon::silver(encodeString(problems, quote = "`")) warning( "Square root is undefined for ", plu::stick(plu::more(prob_msg, fn = crayon::silver, type = "input.")), call. = FALSE ) } sqrt(x) } ints < round(runif(20, 10, 10)) verbose_sqrt(ints)#> Warning: Square root is undefined for `8`, `7`, `10`, `1`, `4` and 8 more inputs.#> Warning: NaNs produced#> [1] NaN 2.645751 1.414214 NaN NaN NaN 0.000000 NaN #> [9] 2.236068 2.236068 2.645751 NaN NaN NaN NaN NaN #> [17] NaN NaN NaN 3.162278