getwd.Rd 1.6 KB
 Radford Neal committed May 18, 2013 1 2 % File src/library/base/man/getwd.Rd % Part of the R package, http://www.R-project.org  Radford Neal committed Aug 26, 2016 3 % Copyright 1995-2011 R Core Team  Radford Neal committed May 18, 2013 4 5 6 7 8 9 10 11 12 13 14 % Distributed under GPL 2 or later \name{getwd} \alias{getwd} \alias{setwd} \title{Get or Set Working Directory} \usage{ getwd() setwd(dir) } \arguments{  Radford Neal committed May 18, 2013 15  \item{dir}{A character string: \link{tilde expansion} will be done.}  Radford Neal committed May 18, 2013 16 17 } \description{  Radford Neal committed May 18, 2013 18  \code{getwd} returns an absolute filepath representing the current  Radford Neal committed May 18, 2013 19 20 21 22  working directory of the \R process; \code{setwd(dir)} is used to set the working directory to \code{dir}. } \note{  Radford Neal committed May 18, 2013 23 24 25 26 27  Note that the return value is said to be \strong{an} absolute filepath: there can be more than one representation of the path to a directory and on some OSes the value returned can differ after changing directories and changing back to the same directory (for example if symbolic links have been traversed).  Radford Neal committed May 18, 2013 28 }  Radford Neal committed May 18, 2013 29   Radford Neal committed May 18, 2013 30 31 \seealso{ \code{\link{list.files}} for the \emph{contents} of a directory.  Radford Neal committed May 18, 2013 32 33  \code{\link{normalizePath}} for a \sQuote{canonical} path name.  Radford Neal committed May 18, 2013 34 }  Radford Neal committed May 18, 2013 35   Radford Neal committed May 18, 2013 36 \value{  Radford Neal committed May 18, 2013 37  \code{getwd} returns a character string or \code{NULL} if the working  Radford Neal committed May 18, 2013 38  directory is not available.  Radford Neal committed May 18, 2013 39 40 41  On Windows the path returned will use \code{/} as the path separator and be encoded in UTF-8. The path will not have a trailing \code{/} unless it is the root directory (of a drive or share on Windows).  Radford Neal committed May 18, 2013 42 43  \code{setwd} returns the current directory before the change,  Radford Neal committed May 18, 2013 44 45  invisibly and with the same conventions as \code{getwd}. It will give an error if it does not succeed (including if it is not implemented).  Radford Neal committed May 18, 2013 46 }  Radford Neal committed May 18, 2013 47   Radford Neal committed May 18, 2013 48 49 50 51 52 \examples{ (WD <- getwd()) if (!is.null(WD)) setwd(WD) } \keyword{utilities}