title: Automate data substitution in a data frame
body: <p>I am reading a tab-separated .txt file with two fields of data (V1 and V2) into RStudio using <code>read.table</code></p>
  
  <pre><code>    V1      V2
      Ndepmax 3000
      intx    6
      Sdepmax 3000
      inty    6
  </code></pre>
  
  <p>This .txt file contains a list of parameter values that will be used as input to an .exe that will be run from RStudio using the <code>system()</code> command available in base R </p>
  
  <p>I would like to iterate running this .exe with different values for <code>Ndepmax</code></p>
  
  <p>I am planning to pull the values for <code>Ndepmax</code> from another data table by looping through a list of <code>spec_num</code> values and using the <code>vlookup</code> command from the <code>expss</code> package</p>
  
  <pre><code>maxNdep &lt;- vlookup(spec_num, MinMaxNdep, result_column='NDEP30_max')
  </code></pre>
  
  <p>I have not been able to determine how to take these iterative values of <code>maxNdep</code> and use them to replace the value for <code>Ndepmax</code> in the input file that will be passed to the .exe using <code>system()</code></p>
  
  <p>Any advice for how to accomplish this substitution would be very much appreciated. </p>
  
  <p>EDIT: Further code/clarification is included below...</p>
  
  <pre><code># Input parameter file to use for building the string for "clf_cmd"
  in_file = read.table("input.txt")
  head(in_file, 4)
         V1   V2
  1 Ndepmax 3000
  2    intx    6
  3 Sdepmax 3000
  4    inty    6
  
  # File containing min/max Ndep
  MinMaxNdep = read.table(MinMaxNdep, header = TRUE)
  head (MinMaxNdep, 1)
    SPNUM NDEP30_min NDEP30_max
  1 33786    12.7265    22.7265
  
  # Identify species of interest
  # I will ultimately loop through a set of spec_num values, but just starting with a single species for now
  spec_num &lt;- MinMaxNdep$SPNUM[1]
  
  # Define maxNdep value to use for substitution into `in_file`
  library(expss)
  maxNdep &lt;- vlookup(spec_num, MinMaxNdep, result_column='NDEP30_max')
  
  # Substitute value of maxNdep for the value of Ndepmax included in the `in_file` data frame
  # Not sure how to do this???
  # Need to replace the value of 3000 for Ndepmax in the `in_file` data frame with the maxNdep value included in `MinMaxNdep` for spec_num = 33786
  
  # string passed to cmd line for running the .exe
  clf &lt;- system((paste0("clf i:in_file", spec_num, ".in"))
  </code></pre>