Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Get type of all variables

$
0
0

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

#declare a few sample variables
a<-10
b<-"Hello world"
c<-data.frame()

#get all global variables in script and iterate over them
myGlobals<-objects()
for(i in myGlobals){
  print(typeof(i))     #prints 'character'
}

My problem is that typeof(i) always returns character even though variable a and c are not character variables. How can I get the original type of variable inside the for loop?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>