title: Quantitative risk assessment model
body: <pre><code>N=1000
  alpha=0.1 
  
  zerosandones = rbinom(N, 1,alpha)
  
  vector1=sample(c("raw","cooked"),1000,T,prob=c(0.12,.88))
  vector1
  
  densf=NULL
  densft=NULL
  
  for (i in (1:N))
  {   
    if (zerosandones[i]==1 &amp;&amp; vector1[i]=="raw") {densf[i] = 1} 
    else {if(zerosandones[i]==1 &amp;&amp; vector1[i]=="cooked") {densft[i] &lt;- rbinom(1, 1,alpha*0.2)}
    else {if (zerosandones[i]==0 &amp;&amp; vector1[i]=="raw") {densf[i]=0} 
    else {if (zerosandones[i]==0 &amp;&amp; vector1[i]=="cooked") {densft[i]=0}}}}}
  densft
  densf
  </code></pre>
  
  <p>Hey folks,</p>
  
  <p>I am new to R and building a Quantitative risk assessment model. Briefly over here the idea is that we generate a sample of a 1000 0s and 1s and each 0,1 has a raw/cooked associated. all 0s are dropped and we further analyse the 1s. So for example, if there is a one and its raw then the new densf should equal 1 otherwise 0. Similarly, if there is a one and its cooked then the new densft should equal 1 (simulated on the basis of a binomial rv with an alpha of 0.02 in the case above otherwise 0.</p>
  
  <p>That said, that I m in need of some help as the "densf" and "densft" produce a bunch of <code>NaN</code> values, place 0s and 1s at the wrong locations. Please help!</p>