title: How to iteratively pass arguments into an R function
body: <p>For some background, I am creating a plot in R that has a dropdown-style filter, and to create the filter I need to pass into a function what all of the values are. </p>
  
  <p>My question applies to situations besides just creating plots, though.</p>
  
  <p>Essentially, each argument I'm passing is the same, with the index changing ([1] up to [8]). Is there a more concise way of writing this? This will come in handy when I create a plot that has 30+ dropdown options.</p>
  
  <pre><code>buttons = list(
    unique(df$FAC_DESCRIPTION)[1],
    unique(df$FAC_DESCRIPTION)[2],
    unique(df$FAC_DESCRIPTION)[3],
    unique(df$FAC_DESCRIPTION)[4],
    unique(df$FAC_DESCRIPTION)[5],
    unique(df$FAC_DESCRIPTION)[6],
    unique(df$FAC_DESCRIPTION)[7],
    unique(df$FAC_DESCRIPTION)[8]
  )
  </code></pre>
  
  <p><strong>EDIT:</strong> The code I pasted above is actually a simplified version of what I'm actually trying to do, and when I used the [1:8] method it didn't work. This is closer to the actual code (shortened to the first three elements only, not 8:</p>
  
  <pre><code>buttons = list(
              list(method = "r",args = list("t[0].value", unique(df$FAC)[1]),label =unique(df$FAC)[1]), 
              list(method = "r",args = list("t[0].value", unique(df$FAC)[2]),label =unique(df$FAC)[2]), 
              list(method = "r",args = list("t[0].value", unique(df$FAC)[3]),label =unique(df$FAC)[3])
  )
  </code></pre>
  
  <p>However, when I tried the below, it didn't work -- is that because I'm using it in two places?</p>
  
  <pre><code>buttons = list(
              list(method = "r",args = list("t[0].value", unique(df$FAC)[1:3]),label =unique(df$FAC)[1:3])
  )
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>dropdown_options &lt;- lapply(1:5, function(x)list(paste('method = "r", args = list("transforms[0].value", unique(df$FAC)[',x,']),label = unique(df$FAC)[',x,']',sep='')))
  
  buttons = do.call(list, dropdown_options)
  </code></pre>
  
  <p>But that didn't work either.</p>