title: set a loop to use a function in r
body: <p>I have a dataframe with three columns and I would like to calculate 95% Upper tolerance levels for each variable in media. Here is how the data looks like:
  So, for plastic and water I need to calculate tolerance levels separately for each variable and write it as 4th column. I am using </p>
  
  <pre><code>nptol.int(data$result, alpha = 0.05, P = 0.95, side = 1, method=c("WILKS")) 
  </code></pre>
  
  <p>function.</p>
  
  <pre><code>media   variable    result
  plastic A   2.3
  plastic B   4
  plastic C   4.6
  plastic D   3
  plastic A   2
  plastic B   5
  plastic C   6.7
  plastic A   8
  plastic B   5
  plastic C   4
  water   A   2
  water   B   4
  water   C   5
  water   A   8.2
  water   B   4
  water   C   5
  plastic A   6
  plastic B   7
  plastic C   11.2
  </code></pre>
  
  <p>Thanks,</p>