title: R: How to read a column, find a value and calculate something in another column based in this search?
body: <p>I have a database with 2000 values and it looks like this:</p>
  
  <pre><code>Status     Job          Hours  Salary
  Permanent  Programmer   40      45k
  Permanent  Analyst      35      50k
  Temporary  Programmer   35      47k
  Permanent  Programmer   40      47k
  Temporary  Technician   35      50k
  .
  .
  .
  </code></pre>
  
  <p>I want to do different things with this database, can you guys help me, please?</p>
  
  <p>1: I need to calculate how many <strong>programmers</strong> are <strong>permanent</strong>. And calculate the %.
  I used this code but it didn't work (it calculates only the first 200 employees and not 2000). Furthermore, I don't know how to use the result to calculate a % :(</p>
  
  <pre><code>filter(database, Job == "Programmer" &amp; Status == "Permanent")
  </code></pre>
  
  <p>2: I believe this one is easier but I don't understand too...
  I need to calculate the mean(hours) of all the <strong>Analysts</strong>.
  I tried this but it didn't work:</p>
  
  <pre><code>if(Job == "Analyst"){mean(Hours)}
  </code></pre>
  
  <p>3: I need to use <strong>sample</strong> for this one I know this, but it doesn't work too hahaha (it is hard to begin with R no? Or it's just me?). I need to sample 50 employees and repeat this process 1000 times. The objective is to calculate a confidence interval with 90%.
  I tried this one:</p>
  
  <pre><code>x &lt;- 1
  if(x != 1000){sample(database, 50)}
  </code></pre>
  
  <p>But it doesn't work ahaha, and for the confidence interval part I did not started it.</p>
  
  <p>Because of the distance classes, it's hard for my teacher to help us so we need to find the answers alone. And all the documentation he gave us is the distributions (standard, poisson, geometrical...) and the graphics (hist, boxplot...).</p>
  
  <p>A big thanks to you all :)
  Have a good day!</p>