File commands
# get working directory
getwd()
"/home/username"
# show content of current folder
dir()
"Desktop" "Downloads"
# cd change into a directory
setwd('/path/to/new/directory')
# change to directory "Desktop"
setwd('Desktop')
# change back to parent directory "/home/username"
setwd('..')
# Path in Windows
a) use double backslash (to avoid string interpretation by R)
filepath=('C:\\path\\to\\file.tsv')
b) using slash instead of backslash, also for Windows path in R
filepath=('C:/path/to/file.tsv')
# platform specific file separator: "/" Unix or "\" Windows
.Platform$file.sep
path = paste(path, .Platform$file.sep, filename, sep=''")
# create path of directory and file name
path = paste(filedir, filename, sep = "/")
path = paste(filedir, filename, sep=.Platform$file.sep)
# or, better using file.path:
file.path(getwd(), 'myfile.txt')
# path completion
'~/Projects/ ... <Tab>
# create dir, if doesn't exist
mydir = 'testDir'
if !file.exists(mydir) dir.create(mydir)
Read more
http://stat.ethz.ch/R-manual/R-patched/library/base/html/files.html