vec2assign | R Documentation |
Function to convert a vector to a string formated like 'c("elt1", "elt2", ...)' so it can be used to assign a variable with the content of the vector without having to rerun the code used to make it.
vec2assign(vec)
vec |
a vector object |
a character vector of length 1 where the function was called.
islands_startingWithA <- grep("^A", names(islands), value = TRUE) |> vec2assign(vec = _)
# if the function is there more than once in the document,
# add a separator ('#---') after the line if you run code with ctrl + enter
# since when doing that the range starts on the next line of text, so if the
# function is there too it will act there instead
# You can also use alt + enter to run the single line or
# select the text calling the function to run it.
islands_startingWithA <- grep("^A", names(islands), value = TRUE) |> vec2assign(vec = _)
#---
grep("^A", names(islands), value = TRUE) |> vec2assign(vec = _)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.