SplitPath.Rd
Split a full path in its components. This is specifically an issue in Windows and not really interesting for other OSs.
SplitPath(path, last.is.file = NULL)
a path
logical, determining if the basename should be interpreted as filename or as last directory. If set to NULL
(default), the last entry will be interpreted if the last character is either \ or / and as filename else.
A list, containing the following components:
the normalized path as returned by normalizePath
the drive if the OS is Windows, NA
else
the path without directory and without filename
the filename including extension
the filename without extension
the file extension
if (FALSE) # Windows-specific example
path <- "C:/Documents/Projects/Import/eyestudy.dta"
SplitPath(path)
#> Error in eval(expr, envir, enclos): object 'path' not found
path <- "C:/Documents/Projects/Import/"
SplitPath(path)
#> $normpath
#> [1] "C:/Documents/Projects/Import/"
#>
#> $drive
#> [1] NA
#>
#> $dirname
#> [1] "C:/Documents/Projects/Import/"
#>
#> $fullfilename
#> [1] NA
#>
#> $fullpath
#> [1] "C:/Documents/Projects/"
#>
#> $filename
#> [1] NA
#>
#> $extension
#> [1] NA
#>
path <- "C:/Documents/Projects/Import"
SplitPath(path) # last entry will be taken as filename
#> $normpath
#> [1] "C:/Documents/Projects/Import"
#>
#> $drive
#> [1] NA
#>
#> $dirname
#> [1] "C:/Documents/Projects/"
#>
#> $fullfilename
#> [1] "Import"
#>
#> $fullpath
#> [1] "C:/Documents/Projects/"
#>
#> $filename
#> [1] "Import"
#>
#> $extension
#> [1] NA
#>
SplitPath(path, last.is.file=FALSE)
#> $normpath
#> [1] "C:/Documents/Projects/Import"
#>
#> $drive
#> [1] NA
#>
#> $dirname
#> [1] "C:/Documents/Projects/Import/"
#>
#> $fullfilename
#> [1] NA
#>
#> $fullpath
#> [1] "C:/Documents/Projects/"
#>
#> $filename
#> [1] NA
#>
#> $extension
#> [1] NA
#>