View source: R/R04-Data_wrangling.R
camr_list_elements | R Documentation |
Function to generate R code listing the distinct
elements of x
(e.g., embedding them in a
concatenate or list statement).
camr_list_elements(
x,
left = " \"",
right = "\",\n",
first = "c(\n",
last = ")",
drop_last = ",",
console = TRUE
)
x |
A vector of values. |
left |
A character string to attach
to the left of each element in |
right |
A character string to attach
to the right of each element in |
first |
A character string to attach to the left of the final collapsed string. |
last |
A character string to attach to the right of the final collapsed string. |
drop_last |
An optional character string indicating any patterns to remove from the final element. |
console |
A logical value; if |
Either a message to the console window or a character string.
camr_list_elements( LETTERS[1:3] )
# Operates only on distinct values
camr_list_elements( rep( LETTERS[1:3], each = 2 ) )
# Can adjust how elements are embedded in R code
camr_list_elements( 1:3, left = ' ', right = ',\n' )
camr_list_elements( LETTERS[1:3], first = 'list(\n' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.