Learn R Programming

cgwtools (version 4.1)

getstack: Returns the current directory stack that pushd and popd manipulate

Description

getstack goes into the separate environment where pushd and popd operate and returns the current stack of directories.

Usage

getstack()

Value

The current directory stack is returned as a vector of strings.

Arguments

none

Author

Carl Witthoft carl@witthoft.com

Details

Allowing a function to modify an object in the GlobalEnvironment is frowned upon by CRAN (and most programmers), so to maintain a directory stack a separate environment is established by pushd. Since this environment is not visible at the console level, getstack allows the user to check on the current status of the stack.

See Also

popd , pushd, setwd

Examples

Run this code
## depends on your local directory structure and permissions
getwd()
getstack() #empty, probably
pushd('..')
getstack()
pushd('.')
getstack()
popd()
getstack()
popd()
getstack()
getwd() #back where we started

Run the code above in your browser using DataLab