as.environment {base} | R Documentation

## Coerce to an Environment Object

### Description

Converts a number or a character string to the corresponding environment on the search path.

### Usage

    as.environment(object)

### Arguments

`object` | the object to convert. If it is already an environment, just return it. If it is a number, return the environment corresponding to that position on the search list. If it is a character string, match the string to the names on the search list.

### Value

The corresponding environment object.

### Author(s)

John Chambers

### See Also

`environment` for creation and manipulation, `search`.

### Examples

    as.environment(1) ## the global environment
    identical(globalenv(), as.environment(1)) ## is TRUE
    as.environment("package:ctest")

[Package Contents]