Question: Chromecast session status returns undefined on Chrome mobile ios. The session exists and has other properties defined, like sessionID. On the desktop, the session status returns "connected", "disconnected", or "stopped" as expected. Is this a bug with Chrome ios? Is there another way to detect the session status?

Answer: 
Here's one alternative using `ifelse`

```
> transform(df, NewSize=ifelse(Month==1, Size*Month1, 
                  ifelse(Month==2, Size*Month2, Size*Month3)))
  Orig Dest Month Size Month1 Month2 Month3 NewSize
1    A    B     1   30    1.0    0.6    0.0      30
2    B    A     1   20    0.2    1.0    1.0       4
3    A    C     1   10    0.0    0.0    0.6       0
4    A    B     2   10    1.0    0.6    0.0       6
5    B    A     2   20    0.2    1.0    1.0      20
6    A    C     2   20    0.0    0.0    0.6       0
7    A    B     3   30    1.0    0.6    0.0       0
8    B    A     3   50    0.2    1.0    1.0      50
9    A    C     3   20    0.0    0.0    0.6      12

```
You can use `apply`:

```
apply(df, 1, function(u) as.numeric(u[paste0('Month', u['Month'])])*as.numeric(u['Size']))
#[1] 30  4  0  6 20  0  0 50 12

```

Or a vectorized solution:

```
bool = matrix(rep(df$Month, each=3)==rep(1:3, nrow(df)), byrow=T, ncol=3)

df[c('Month1', 'Month2', 'Month3')][bool] * df$Size
#[1] 30  4  0  6 20  0  0 50 12

```