title: Setting the default value in a function?
body: <p>I have a simple density function below:</p>
  
  <pre><code>dpower &lt;- function(x, b, r){
  if ((b &lt;= 0 | r &lt;= 0)) 
  return("Wrong parameters entered!")
  else{
   density.temp &lt;- (r/b)*(x/b)^(r - 1)
   density.temp[which(x &gt;= b | x &lt;= 0)] &lt;- NA
   return(density.temp)
   } 
  }
  </code></pre>
  
  <p>This function returns density corresponding to value x from the specified distribution with parameters b and r. I'd like to set the default value on x that if the user doesn't specify x, the default values passes through. We can simply set dpower &lt;- function(x = x.default, b, r)... however, my default value depends on r and b. How can I do that? suppose the default value for x is:</p>
  
  <pre><code>seq(from = 0.05, to = b, by = 0.001)
  </code></pre>
  
  <p>Thanks for your help,</p>