title: Get type of all variables
body: <p>In R, I'd like to retrieve a list of global variables at the end of my script and iterate over them. Here is my code</p>
  
  <pre><code>#declare a few sample variables
  a&lt;-10
  b&lt;-"Hello world"
  c&lt;-data.frame()
  
  #get all global variables in script and iterate over them
  myGlobals&lt;-objects()
  for(i in myGlobals){
    print(typeof(i))     #prints 'character'
  }
  </code></pre>
  
  <p>My problem is that <code>typeof(i)</code> always returns <code>character</code> even though variable <code>a</code> and <code>c</code> are not character variables. How can I get the original type of variable inside the for loop?</p>