在R中,我希望检索脚本末尾的全局变量列表,并对它们进行迭代。以下是我的代码
#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'
}
我的问题是,即使变量a
和c
不是字符变量,typeof(i)
也总是返回character
。如何在for循环中获得变量的原始类型?
https://stackoverflow.com/questions/12693908
复制相似问题