Switch list elements with their names
revertListAssignments(x)
x | list of named elements |
---|
list with the names of x as elements and the elements of x as names
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