title: Parsing a string in R
body: <p>I am writing a R script which I will be running as a script from the command line. I am passing command line arguments to the script using keywords as follows:</p>
  
  <p>myscript.R --arg1=100 --arg2='hello' --arg3=3.14159</p>
  
  <p>I want to write an R function that will return the command line values into a dictionary like object (i.e. a list of lists in R), filling unsupplied arguments with defaults.</p>
  
  <p>for e.g.</p>
  
  <pre><code>parseArguments &lt;- function() {
      options &lt;- commandArgs(TRUE)
  
      # options now contains "--arg1=100 --arg2='hello' --arg3=3.14159"
      # parse string held in variable named options and stuff into a list 
      # .... Do some string manip ....
  
      args &lt;- list()
      args['arg1'] &lt;- 100
      args['arg2'] &lt;- 'hello'
      args['arg3'] &lt;- 3.14159
      args['arg4'] &lt;- 123  # Not found in parsed line so we use a hard coded default
  
      return (args)
  }
  </code></pre>
  
  <p>Can someone help fill in the blanks?</p>