Just learning dplyr (and R) and I do not understand why this fails or what the correct approach to this is. I am looking for a general explanation rather than something specific to this contrived dataset.

Assume I have 3 files sizes with multipliers and I'd like to combine them into a single numeric column.

```
require(dplyr)

m <- data.frame(
    K = 1E3, 
    M = 1E6, 
    G = 1E9
)

s <- data.frame(
    size = 1:3,
    mult = c('K', 'M', 'G')
)

```

Now I want to multiply the size by it's multiplier so I tried:

```
mutate(s, total = size * m[[mult]])

#Error in .subset2(x, i, exact = exact) : 
#    recursive indexing failed at level 2 

```

which throws an error. I also tried:

```
mutate(s, total = size * as.numeric(m[mult]))

#1    1    K 1e+06
#2    2    M 2e+09
#3    3    G 3e+03

```

which is worse than an error (wrong answer)!

I tried a lot of other permutations but could not find the answer.

Thanks in advance!

---

Edit:  

(*or should this be another question*)  

akrun's answer worked great and I thought I understood but if I

```
rbind(s, c(4, NA))

```

then update the mutate to

```
mutate(s, total = size * 
    ifelse(is.na(mult), 1,
        unlist(m[as.character(mult)])

```

it falls apart again with an "undefined columns selected"