title: Embeded Conditional expression
body: <p>I have a vector and a constant which I use in the expression below:   a through i are the results of a function</p>
  
  <pre><code>Y&lt;- c(0.2,0.09,0.3,0.2,0.4,0.5,0.2,0.1,1)
  x&lt;- 0.13
  G&lt;-if(tail(Y,1)==1)
  
  {a &lt;- g*h
  b &lt;- i*r
  d &lt;- o*p
  e &lt;- j*k
  f &lt;- s*y
  g &lt;- t*w
  h &lt;- v*l
  i &lt;- n*m
  
  if(x &lt; 0.1)  a else 0+
  if(x &lt; 0.11)  b else 0+
  if(x &lt; 0.12)  c else 0+
  if(x &lt; 0.13)  d else 0+
  if(x &lt; 0.14)  e else 0+
  if(x &lt; 0.15)  f else 0+
  if(x &lt; 0.16)  g else 0+
  if(x &lt; 0.17)  h else 0+
  if(x &lt; 0.18)  i else 0}  else 0 
  
  G
  [1] 30
  </code></pre>
  
  <p>I would like to obtain result G which is the output of the sum of the first 3 (a,b,c) within the last expression between {}. Have tried with ifelse and does not work as it selects only just one as in the example above. </p>
  
  <p>a through i are the results of a function, example below (can not place the function and the vector as is too long) and can not be sequenced as per the factors above exposed.</p>
  
  <pre><code>{a &lt;- summary(ResFit)$coef[55]*summary(ResFit)$coef[91]
  b &lt;- summary(ResFit)$coef[56]* summary(ResFit)$coef[93]
  c &lt;- summary(ResFit)$coef[57]*summary(ResFit)$coef[95]
  d &lt;- summary(ResFit)$coef[58]*summary(ResFit)$coef[97]
  e &lt;- summary(ResFit)$coef[50]*summary(ResFit)$coef[99]
  f &lt;- summary(ResFit)$coef[59]*summary(ResFit)$coef[101]
  g &lt;- summary(ResFit)$coef[60]*summary(ResFit)$coef[103]
  h &lt;- summary(ResFit)$coef[61]*summary(ResFit)$coef[105]
  i &lt;- summary(ResFit)$coef[62]*summary(ResFit)$coef[107]
  </code></pre>
  
  <p>Many thanks </p>