EVOLUTION-MANAGER
Edit File: fileutils.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: File Utilities</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for fileutils {tools}"><tr><td>fileutils {tools}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>File Utilities</h2> <h3>Description</h3> <p>Utilities for listing files, and manipulating file paths. </p> <h3>Usage</h3> <pre> file_ext(x) file_path_as_absolute(x) file_path_sans_ext(x, compression = FALSE) list_files_with_exts(dir, exts, all.files = FALSE, full.names = TRUE) list_files_with_type(dir, type, all.files = FALSE, full.names = TRUE, OS_subdirs = .OStype()) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>character vector giving file paths.</p> </td></tr> <tr valign="top"><td><code>compression</code></td> <td> <p>logical: should compression extension ‘<span class="file">.gz</span>’, ‘<span class="file">.bz2</span>’ or ‘<span class="file">.xz</span>’ be removed first?</p> </td></tr> <tr valign="top"><td><code>dir</code></td> <td> <p>a character string with the path name to a directory.</p> </td></tr> <tr valign="top"><td><code>exts</code></td> <td> <p>a character vector of possible file extensions (excluding the leading dot).</p> </td></tr> <tr valign="top"><td><code>all.files</code></td> <td> <p>a logical. If <code>FALSE</code> (default), only visible files are considered; if <code>TRUE</code>, all files are used.</p> </td></tr> <tr valign="top"><td><code>full.names</code></td> <td> <p>a logical indicating whether the full paths of the files found are returned (default), or just the file names.</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>a character string giving the ‘type’ of the files to be listed, as characterized by their extensions. Currently, possible values are <code>"code"</code> (R code), <code>"data"</code> (data sets), <code>"demo"</code> (demos), <code>"docs"</code> (R documentation), and <code>"vignette"</code> (vignettes).</p> </td></tr> <tr valign="top"><td><code>OS_subdirs</code></td> <td> <p>a character vector with the names of OS-specific subdirectories to possibly include in the listing of R code and documentation files. By default, the value of the environment variable <span class="env">R_OSTYPE</span>, or if this is empty, the value of <code><a href="../../base/html/Platform.html">.Platform</a>$OS.type</code>, is used.</p> </td></tr> </table> <h3>Details</h3> <p><code>file_ext</code> returns the file (name) extensions (excluding the leading dot). (Only purely alphanumeric extensions are recognized.) </p> <p><code>file_path_as_absolute</code> turns a possibly relative file path absolute, performing tilde expansion if necessary. This is a wrapper for <code><a href="../../base/html/normalizePath.html">normalizePath</a></code>. Currently, <code>x</code> must be a single existing path. </p> <p><code>file_path_sans_ext</code> returns the file paths without extensions (and the leading dot). (Only purely alphanumeric extensions are recognized.) </p> <p><code>list_files_with_exts</code> returns the paths or names of the files in directory <code>dir</code> with extension matching one of the elements of <code>exts</code>. Note that by default, full paths are returned, and that only visible files are used. </p> <p><code>list_files_with_type</code> returns the paths of the files in <code>dir</code> of the given ‘type’, as determined by the extensions recognized by <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>. When listing R code and documentation files, files in OS-specific subdirectories are included if present according to the value of <code>OS_subdirs</code>. Note that by default, full paths are returned, and that only visible files are used. </p> <h3>See Also</h3> <p><code><a href="../../base/html/file.path.html">file.path</a></code>, <code><a href="../../base/html/file.info.html">file.info</a></code>, <code><a href="../../base/html/list.files.html">list.files</a></code> </p> <h3>Examples</h3> <pre> dir <- file.path(R.home(), "library", "stats") list_files_with_exts(file.path(dir, "demo"), "R") list_files_with_type(file.path(dir, "demo"), "demo") # the same file_path_sans_ext(list.files(file.path(R.home("modules")))) </pre> <hr /><div style="text-align: center;">[Package <em>tools</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>