User-defined function for pre-evaluated names in vectors
Source:R/utils_general.R
grapes-T-grapes.Rd
Generates a named element. Can be used in conjunction with c()
to
create a collection of named elements
Examples
# Creating a named vector with a static name
vectorElement <- "value" %T% 5
print(vectorElement)
#> value
#> 5
# Creating a combined named vector with both static and dynamic names
nameForElement <- "dynamicName"
combinedVector <- c("staticName" %T% 123, nameForElement %T% 456)
print(combinedVector)
#> staticName dynamicName
#> 123 456
# Note: `%T%` can be especially useful in data manipulation where dynamic
# naming of elements is required. Here's a more complex example:
keyMap <- data.frame(key = "key_01")
dynamicVector <- keyMap$key %T% 10
print(dynamicVector)
#> key_01
#> 10