Based on the suggestion of Señor :
> z$q <- ifelse(z$x == 2, z$t * 2,
ifelse(z$x == 4, z$t * 4,
ifelse(z$x == 7, z$t * 3,
z$t * 1)))
> z
x y t q
1 1 11 21 21
2 2 12 22 44
3 3 13 23 23
4 4 14 24 96
5 5 15 25 25
6 6 16 26 26
7 7 17 27 81
8 8 18 28 28
9 9 19 29 29
10 10 20 30 30