vec2assign_str: Convert a vector into a string formated for assignment

View source: R/vec2assign.R

vec2assign_strR Documentation

Convert a vector into a string formated for assignment

Description

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.

Usage

vec2assign_str(vec)

Arguments

vec

a vector object

Value

a character vector of length 1

Examples

vec <- grep("^A", names(islands), value = TRUE)
cat(vec2assign_str(vec))
# then copy-paste from console to the assignment
# OR save it in clipboard with the clipr package and then paste it to the assignment
# clipr::write_clip(vec2assign_str(vec))
islands_startingWithA <- c("Africa", "Antarctica", "Asia", "Australia", "Axel Heiberg")

salix-d/salix_miscFuns documentation built on Aug. 14, 2024, 7:45 p.m.