show_env <- function(){
listA<-list(ran.in = environment(),
parent = parent.env(environment()),
objects = ls.str(environment())
)
x<-5
ls.str(environment())
# return(listA)
}
> show_env()
listA : List of 3
$ ran.in :<environment: 0x55b5ff4046f8>
$ parent :<environment: R_GlobalEnv>
$ objects:Class 'ls_str' atomic (0)
x : num 5
可是,如果把前面的renturn(listA)加上,运行show_env()就变成了另一个结果了,为什么?
$ran.in
<environment: 0x55b5ff5d9530>
$parent
<environment: R_GlobalEnv>
$objects
--
FROM 125.86.88.*