Description Usage Arguments Details Value Examples
Used as a helper function in vec_print
to make output row strings.
Prints out a vector columnwise, using the full width available. This is usually called for its side effects, but will also return the (unformatted) output rows vector.
1 2 3 4 5 6 7 8 9 10 11 | make_output_rows(vec, numCols, maxChars)
vec_print(
vec,
indent = 0,
maxLen = 20,
maxWidth = getOption("width") - indent,
order = "none",
printOut = TRUE,
color = "#00FF00"
)
|
vec |
The (atomic) vector to print out. |
numCols |
The number of columns to use in the output (integer scalar). |
maxChars |
The maximum number of characters to print for each element of |
indent |
Number of spaces to indent the output by (integer scalar), or a string to use as the indent (character scalar). |
maxLen |
The maximum length of a string to print out (integer scalar). |
maxWidth |
The mxximum width to print out per row (defaults to fill available space) (integer scalar). |
order |
How to order the |
printOut |
Whether to print out the formatted output (logical scalar). |
color |
The color of the output, which can be any valid input to |
order
can be one of three values: c("none" (default), "sort", "short"/"shortest")
order = "none"
will print out the vector in the same order it was supplied.
order = "sort"
will sort the vector before printing (using sort
).
order = "short"/"shortest"
will sort the vector according to length,
which will ensure that the printing takes up as little space as possible.
The output rows vector.
The final output row vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | set.seed(112)
fruits <- sample(c("apple", "banana", "cherry", "orange", "pineapple",
"really very long fruit name"), 100, replace = TRUE)
vec_print(fruits)
vec_print(fruits, maxLen = 20)
vec_print(fruits, maxWidth = 50)
vec_print(fruits, order = "sort")
vec_print(fruits, order = "shortest")
vp <- vec_print(fruits, printOut = FALSE)
vp
## Not run:
vec_print(lexicon::sw_fry_25)
vec_print(rep(lexicon::sw_fry_25, 2))
vec_print(lexicon::sw_fry_100)
vec_print(lexicon::sw_fry_200)
vec_print(lexicon::sw_fry_1000)
vec_print(lexicon::sw_fry_200, maxLen = 5)
vec_print(lexicon::sw_fry_200, maxLen = 20)
vec_print(lexicon::sw_fry_200, maxWidth = 50)
vec_print(lexicon::sw_fry_1000, order = "sort")
vec_print(lexicon::sw_fry_1000, order = "shortest")
vp <- vec_print(lexicon::sw_fry_1000, order = "shortest", printOut = FALSE)
vp
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.