r - Assigning a large number of variables (from a lookup table?) -


i have two-column lookup table names in first column , non-sequential numbers in second column:

name    number arcbo     16 arcgl     41 borsa    534 elegr    121 gadma    249 gadmo    448 

my ultimate goal able pass name script, , script return name's associated number. envisioned doing similar building dictionary in python, perhaps using hash, i'm still new r , environments appear quite challenging. there way approach this? tried ultimate simple solution of iterating through table follows:

for (i in (1:nrow(lookuptable))){ + lookuptable[i,2] <- lookuptable[i,1] + } 

but replace number name, such have 2 columns of names , no numbers.

lookuptab[lookuptab$name==lookupvalue,2] 

or, function:

lookup <- function(lookupvalue)     lookuptab[lookuptab$name==lookupvalue,2] lookup("arcbo") lookup("gadma") 

Comments