Switch list elements with their names
Arguments
- x
list of named elements
Value
list with the names of x as elements and the elements of
x as names
Examples
abbreviation <- list(de = "Germany", en = "England")
revertListAssignments(abbreviation)
#> $Germany
#> [1] "de"
#>
#> $England
#> [1] "en"
#>
## reverting twice results in the original list
identical(
abbreviation,
revertListAssignments(revertListAssignments(abbreviation))
)
#> [1] TRUE