user2720097
user2720097

Reputation: 509

Get environment identifier in R

I'm working with an environment, and I need the identifier of this environment. The function environmentName() doesn't work. It returns "", so how can I get the identifier of a environment?

Example:

a #this is a environment
<environment: 0xbc6d2bc>
environmentName(a)
""

I need this id "0xbc6d2bc".

Note: I didn't create the environment

Upvotes: 7

Views: 486

Answers (1)

eddi
eddi

Reputation: 49448

There might be a function that does this for you, but you can always just capture the output and extract that number yourself:

sub('<environment: (.*)>', '\\1', capture.output(a))

edit: there is a function in data.table that does this for you:

library(data.table)

address(a)

Upvotes: 10

Related Questions