helper tools for the R# programming
utils
01 Syntax
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| progress_bar | 1 | Create a progress bar helper function |
| setTqdmProgressBarlabel | 1 | set progress task for current used tqdm wrapped progressbar in for loop |
| tqdm_wrap | 1 | Wraps a collection with a progress bar for iteration, providing visual feedback on progress. |
| installPackages | 1 | Install Packages from Repositories or Local Files Download and install packages from CRAN-like repositories or from local files. |
| GetInstalledPackages | 1 | Find Installed Packages Find (or retrieve) details of all packages installed in the specified libraries. |
| keyGroups | 1 | |
| wget_file | 1 | retrieving files using HTTP, HTTPS, FTP and FTPS, the most widely used Internet protocols. |
| cls | 1 | Clears the console buffer and corresponding console window of display information. |
| sleep | 1 | Suspends the current thread for the specified number of seconds. |
| stack | 1 | Stack or Unstack Vectors from a Data Frame or List Stacking vectors concatenates multiple vectors into a single vector along with a factor indicating where each observation orig… |
| head | 1 | Return the First or Last Part of an Object Returns the first or last parts of a vector, matrix, table, data frame or function. |
| memorySize | 1 | Report on Memory Allocation memory.size reports the current or maximum memory allocation of the malloc function used in this version of R. |
| createCommandLine | 1 | create commandline string |
| createArgumentString | 2 | build commandline argument string from a tuple list object |
| system2 | 1 | Invoke a System Command system2 invokes the OS command specified by command. |
| shQuote | 1 | Quote Strings for Use in OS Shells Quote a string to be passed to an operating system shell. |
| Sys_which | 1 | Find Full Paths to Executables This is an interface to the system command which, or to an emulation on Windows. |
| Sys_chmod | 1 | Manipulation of Directories and File Permissions These functions provide a low-level interface to the computer's file system. |
| system | 1 | Invoke a System Command system invokes the OS command specified by command. |
| workdir | 1 | Create a new temporary work directory environment for the code |
| md5 | 1 | Vectorized hash/hmac functions |
| debugTool | 1 | Debug an Expression apply for debug in Visual Studio, like a script breakpoint |
| pause | 1 | Pause the current console program. |
| data | 1 | Data Sets Loads specified data sets, or list the available data sets. |
| dataSearchByPackageDir | 1 | |
| systemFile | 1 | Find Names of R System Files Finds the full file names of files in packages etc. |
| description | 1 | loading a DESCRIPTION file |
| now | 1 | get current system time |
| createTimespan | 1 | create the time span value based on the given time ticks |
| package_skeleton | 1 | Create a Skeleton for a New Source Package package.skeleton automates some of the setup for a new source package. |
| unzipFile | 1 | Extract or List Zip Archives Extract files from or list a zip archive. |
| create_zip | 1 | Create Zip Archives A wrapper for an external zip command to create zip archives. |
| sendMessage | 1 | send task message to the parent node |
03 Members
Int32, Int32, Int32)Create a progress bar helper function
| Name | Type | Description |
|---|---|---|
total | Int32 | - |
width | Int32 | - |
interval | Int32 | the progress display internal, should be value in range [1,100]. |
let bar = progress_bar(total = 10);
bar("test 1"); bar("test 2"); bar("test 3");
String)set progress task for current used tqdm wrapped progressbar in for loop
this function is thread unsafe
| Name | Type | Description |
|---|---|---|
label | String | - |
Wraps a collection with a progress bar for iteration, providing visual feedback on progress.
this function is thread unsafe
| Name | Type | Description |
|---|---|---|
x | Object | The collection to iterate over. |
width | Int32 | The width of the progress bar. |
prints_perSecond | Int32 | The update frequency of the progress bar. |
use_color | Boolean | Indicates whether to use colored output for the progress bar. |
An enumerable that iterates over the collection with progress tracking.
String(), Environment)Install Packages from Repositories or Local Files
Download and install packages from CRAN-like repositories or from local files.
This is the main function to install packages. It takes a vector of names and a destination library, downloads the packages from the repositories and installs them. (If the library is omitted it defaults to the first directory in .libPaths(), with a message if there is more than one.) If lib is omitted or is of length one and is not a (group) writable directory, in interactive use the code offers to create a personal library tree (the first element of Sys.getenv("R_LIBS_USER")) and install there. Detection of a writable directory is problematic on Windows: see the ‘Note’ section.
For installs from a repository an attempt Is made To install the packages In an order that respects their dependencies. This does assume that all the entries In Lib are On the Default library path For installs (Set by environment variable R_LIBS).
You are advised To run update.packages before install.packages To ensure that any already installed dependencies have their latest versions.
install.packages tries to detect if you have write permission on the library directories specified, but Windows reports unreliably. If there is only one library directory (the default), R tries to find out by creating a test directory, but even this need not be the whole story: you may have permission to write in a library directory but lack permission to write binary files (such as ‘.dll’ files) there. See the ‘R for Windows FAQ’ for workarounds.
| Name | Type | Description |
|---|---|---|
packages | String() | The dll file name, character vector of the names of packages whose current versions should be downloaded from the repositories. |
envir | Environment | - |
String, Environment)Find Installed Packages
Find (or retrieve) details of all packages installed in the specified libraries.
installed.packages scans the ‘DESCRIPTION’ files of each package found along lib.loc and returns a matrix of package names, library paths and version numbers.
The information found Is cached (by library) For the R session And specified fields argument, And updated only If the top-level library directory has been altered, For example by installing Or removing a package. If the cached information becomes confused, it can be refreshed by running installed.packages(noCache = True).
| Name | Type | Description |
|---|---|---|
envir | String | - |
String())| Name | Type | Description |
|---|---|---|
keys | String() | - |
index value is zero based
retrieving files using HTTP, HTTPS, FTP and FTPS, the most widely used Internet protocols.
| Name | Type | Description |
|---|---|---|
url | String | - |
save | Object | this parameter could be a character vector for specific a local file path to save the target remote file, or it also could be a file reference wrapper object for store in a cache pack. This function will returns a stream object if this parameter is nothing. |
env | Environment | - |
this function will returns the data stream which is download from the given url if the save parameter value is nothing by default, or this function will returns nothing if the save parameter value is exists and also the http resource data will be placed at save file location.
Clears the console buffer and corresponding console window of display information.
Double)Suspends the current thread for the specified number of seconds.
| Name | Type | Description |
|---|---|---|
sec | Double | - |
Object, Environment)Stack or Unstack Vectors from a Data Frame or List
Stacking vectors concatenates multiple vectors into a single vector along with a factor indicating where each observation originated. Unstacking reverses this operation.
The stack function is used to transform data available as separate columns in a data frame or list into a single column that can be used in an analysis of variance model or other linear model. The unstack function reverses this operation. Note that stack applies to vectors (as determined by is.vector): non-vector columns (e.g., factors) will be ignored with a warning. Where vectors of different types are selected they are concatenated by unlist whose help page explains how the type of the result is chosen. These functions are generic: the supplied methods handle data frames and objects coercible to lists by as.list.
| Name | Type | Description |
|---|---|---|
x | Object | a list or data frame to be stacked or unstacked. |
env | Environment | - |
unstack produces a list of columns according to the formula form. If all the columns have the same length, the resulting list is coerced to a data frame. stack produces a data frame with two columns: values the result of concatenating the selected vectors in x. ind a factor indicating from which vector in x the observation originated.
Return the First or Last Part of an Object
Returns the first or last parts of a vector, matrix, table, data frame or function. Since head() and tail() are generic functions, they may also have been extended to other classes.
For matrices, 2-dim tables and data frames, head() (tail()) returns the first (last) n rows when n >= 0 or all but the last (first) n rows when n < 0. head.matrix() and tail.matrix() are exported. For functions, the lines of the deparsed function are returned as character strings.
If a matrix has no row names, Then tail() will add row names Of the form "[n,]" To the result, so that it looks similar To the last lines Of x When printed. Setting addrownums = False suppresses this behaviour.
| Name | Type | Description |
|---|---|---|
x | Object | an object |
n | Int32 | a single integer. If positive or zero, size for the resulting object: number of elements for a vector (including lists), rows for a matrix or data frame or lines for a function. If negative, all but the n last/first number of elements of x. |
env | Environment | - |
An object (usually) like x but generally smaller. For ftable objects x, a transformed format(x).
Boolean)Report on Memory Allocation
memory.size reports the current or maximum memory allocation of the malloc function used in this version of R.
| Name | Type | Description |
|---|---|---|
max | Boolean | logical. If TRUE the maximum amount of memory obtained from the OS Is reported, if FALSE the amount currently in use, if NA the memory limit. |
Size in Mb (1048576 bytes), rounded to 0.01 Mb for memory.size
create commandline string
| Name | Type | Description |
|---|---|---|
argv | list | - |
env | Environment | - |
build commandline argument string from a tuple list object
| Name | Type | Description |
|---|---|---|
argv | list | - |
env | Environment | - |
Object, Environment)generates commandline arguments string from different types of input data
| Name | Type | Description |
|---|---|---|
args | Object | - |
env | Environment | - |
String, Object, Object, Object, String, Object, Boolean, Boolean, Boolean, Single, Boolean, Boolean, Nullable(Of Boolean), Environment)Invoke a System Command
system2 invokes the OS command specified by command.
Unlike system, command is always quoted by shQuote, so it must be a single command without arguments.
For details of how command is found see system.
On Windows, env is only supported for commands such as R and make which accept environment variables on their command line.
Some Unix commands (such as some implementations of ls) change their output if they consider it to be piped or redirected: stdout = TRUE uses a pipe whereas stdout = "some_file_name" uses redirection.
Because of the way it is implemented, on a Unix-alike stderr = TRUE implies stdout = TRUE: a warning is given if this is not what was specified.
When timeout is non-zero, the command is terminated after the given number of seconds. The termination works for typical commands, but is not guaranteed: it is possible to write a program that would keep running after the time is out. Timeouts can only be set with wait = TRUE.
system2 is a more portable and flexible interface than system. It allows redirection of output without needing to invoke a shell on Windows, a portable way to set environment variables for the execution of command, and finer control over the redirection of stdout and stderr. Conversely, system (and shell on Windows) allows the invocation of arbitrary command lines.
There is no guarantee that if stdout and stderr are both TRUE or the same file that the two streams will be interleaved in order. This depends on both the buffering used by the command and the OS.
| Name | Type | Description |
|---|---|---|
command | String | the system command to be invoked, as a character string. |
args | Object | a character vector of arguments to command. |
stdout | Object | where output to ‘stdout’ or ‘stderr’ should be sent. Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file. |
stderr | Object | where output to ‘stdout’ or ‘stderr’ should be sent. Possible values are "", to the R console (the default), NULL or FALSE (discard output), TRUE (capture the output in a character vector) or a character string naming a file. |
stdin | String | should input be diverted? "" means the default, alternatively a character string naming a file. Ignored if input is supplied. |
input | Object | if a character vector is supplied, this is copied one string per line to a temporary file, and the standard input of command is redirected to the file. |
wait | Boolean | a logical (not NA) indicating whether the R interpreter should wait for the command to finish, or run it asynchronously. This will be ignored (and the interpreter will always wait) if stdout = TRUE or stderr = TRUE. When running the command asynchronously, no output will be displayed on the Rgui console in Windows (it will be dropped, instead). |
minimized | Boolean | logical (not NA), indicates whether the command window should be displayed initially as a minimized window. |
invisible | Boolean | logical (not NA), indicates whether the command window should be visible on the screen. |
timeout | Single | timeout in seconds, ignored if 0. This is a limit for the elapsed time running command in a separate process. Fractions of seconds are ignored. |
env | Boolean | character vector of name=value strings to set environment variables. |
If stdout = TRUE or stderr = TRUE, a character vector giving the output of the command, one line per character string. (Output lines of more than 8095 bytes will be split.) If the command could not be run an R error is generated. If command runs but gives a non-zero exit status this will be reported with a warning and in the attribute "status" of the result: an attribute "errmsg" may also be available.
In other cases, the return value is an error code (0 for success), given the invisible attribute (so needs to be printed explicitly). If the command could not be run for any reason, the value is 127 and a warning is issued (as from R 3.5.0). Otherwise if wait = TRUE the value is the exit status returned by the command, and if wait = FALSE it is 0 (the conventional success value).
If the command times out, a warning is issued and the exit status is 124.
Some Windows commands return out-of-range status values (e.g., -1) and so only the bottom 16 bits of the value are used.
Object, Object)Quote Strings for Use in OS Shells
Quote a string to be passed to an operating system shell.
The default type of quoting supported under Unix-alikes is that for the Bourne shell sh. If the string does not contain single quotes, we can just surround it with single quotes. Otherwise, the string is surrounded in double quotes, which suppresses all special meanings of metacharacters except dollar, backquote and backslash, so these (and of course double quote) are preceded by backslash. This type of quoting is also appropriate for bash, ksh and zsh.
The other type of quoting is for the C-shell (csh and tcsh). Once again, if the string does not contain single quotes, we can just surround it with single quotes. If it does contain single quotes, we can use double quotes provided it does not contain dollar or backquote (and we need to escape backslash, exclamation mark and double quote). As a last resort, we need to split the string into pieces not containing single quotes (some may be empty) and surround each with single quotes, and the single quotes with double quotes.
In Windows, command line interpretation is done by the application as well as the shell. It may depend on the compiler used: Microsoft's rules for the C run-time are given at https://learn.microsoft.com/en-us/cpp/c-language/parsing-c-command-line-arguments?view=msvc-160. It may depend on the whim of the programmer of the application: check its documentation. The type = "cmd" prepares the string for parsing as an argument by the Microsoft's rules and makes shQuote safe for use with many applications when used with system or system2. It surrounds the string by double quotes and escapes internal double quotes by a backslash. Any trailing backslashes and backslashes that were originally before double quotes are doubled.
The Windows cmd.exe shell (used by default with shell) uses type = "cmd2" quoting: special characters are prefixed with "^". In some cases, two types of quoting should be used: first for the application, and then type = "cmd2" for cmd.exe.
| Name | Type | Description |
|---|---|---|
string | Object | a character vector, usually of length one. |
type | Object | character: the type of shell quoting. Partial matching is supported. "cmd" and "cmd2" refer to the Windows shell. "cmd" is the default under Windows. |
A character vector of the same length as string.
Object)Find Full Paths to Executables
This is an interface to the system command which, or to an emulation on Windows.
The system command which reports on the full path names of an executable (including an executable script) as would be executed by a shell, accepting either absolute paths or looking on the path. On Windows an ‘executable’ is a file with extension ‘.exe’, ‘.com’, ‘.cmd’ or ‘.bat’. Such files need not actually be executable, but they are what system tries. On a Unix-alike the full path to which (usually ‘/usr/bin/which’) is found when R is installed.
Except on Windows this calls the system command which: since that is not part of e.g. the POSIX standards, exactly what it does is OS-dependent. It will usually do tilde-expansion and it may make use of csh aliases.
| Name | Type | Description |
|---|---|---|
names | Object | Character vector of names or paths of possible executables. |
A character vector of the same length as names, named by names. The elements are either the full path to the executable or some indication that no executable of that name was found. Typically the indication is "", but this does depend on the OS (and the known exceptions are changed to ""). Missing values in names have missing return values. On Windows the paths will be short paths (8+3 components, no spaces) with \ as the path delimiter.
Object, String, Boolean, Boolean)Manipulation of Directories and File Permissions
These functions provide a low-level interface to the computer's file system.
Sys.chmod sets the file permissions of one or more files. The interpretation of mode in the Windows system functions is non-POSIX and only supports setting the read-only attribute of the file. So R interprets mode to mean set read-only if and only if (mode & 0200) == 0 (interpreted in octal). Windows has a much more extensive system of file permissions on some file systems (e.g., versions of NTFS) which are unrelated to this system call.
| Name | Type | Description |
|---|---|---|
paths | Object | character vectors containing file or directory paths. Tilde expansion (see path.expand) is done. |
mode | String | the mode to be used on Unix-alikes: it will be coerced by as.octmode. For Sys.chmod it is recycled along paths. |
use_umask | Boolean | logical: should the mode be restricted by the umask setting? |
String, Boolean, Boolean, Boolean, Boolean, Object, Boolean, Boolean, Boolean, Double, Boolean, Environment)Invoke a System Command
system invokes the OS command specified by command.
This interface has become rather complicated over the years: see system2 for a more portable and flexible interface which is recommended for new code.
command Is parsed as a command plus arguments separated by spaces. So if the path to the command (Or a single argument such as a file path) contains spaces, it must be quoted e.g. by shQuote. Only double quotes are allowed on Windows: see the examples. (Note: a Windows path name cannot contain a Double quote, so we Do Not need To worry about escaping embedded quotes.)
command must be an executable (extensions '.exe’, ‘.com’) or a batch file (extensions ‘.cmd’ and ‘.bat’): these extensions are tried in turn if none is supplied. This means that redirection, pipes, DOS internal commands, ... cannot be used: see shell if you want to pass a shell command-line.
The search path For command may be system-dependent: it will include the R 'bin’ directory, the working directory and the Windows system directories before PATH.
When timeout Is non-zero, the command Is terminated after the given number of seconds. The termination works for typical commands, but Is Not guaranteed it Is possible to write a program that would keep running after the time Is out. Timeouts can only be set with wait = TRUE.
The ordering Of arguments after the first two has changed from time To time: it Is recommended to name all arguments after the first.
There are many pitfalls In Using system To ascertain If a command can be run — Sys.which Is more suitable.
| Name | Type | Description |
|---|---|---|
command | String | the system command to be invoked, as a character string. |
intern | Boolean | a logical (not NA) which indicates whether to capture the output of the command as an R character vector. |
ignore_stdout | Boolean | - |
ignore_stderr | Boolean | - |
wait | Boolean | - |
input | Object | - |
show_output_on_console | Boolean | logical (Not NA), indicates whether to capture the output of the command And show it on the R console (Not used by Rterm, which shows the output in the terminal unless wait Is false). |
minimized | Boolean | logical (Not NA), indicates whether a command window should be displayed initially as a minimized window. |
invisible | Boolean | - |
timeout | Double | - |
If intern = TRUE, a character vector giving the output of the command, one line per character string. (Output lines of more than 8095 bytes will be split.) If the command could not be run an R error is generated. Under the Rgui console intern = TRUE also captures stderr unless ignore.stderr = TRUE. If command runs but gives a non-zero exit status this will be reported with a warning and in the attribute "status" of the result: an attribute "errmsg" may also be available.
If intern = False, the Return value Is an Error code (0 For success), given the invisible attribute (so needs To be printed explicitly). If the command could Not be run For any reason, the value Is 127 And a warning Is issued (As from R 3.5.0). Otherwise If wait = True the value Is the Exit status returned by the command, And If wait = False it Is 0 (the conventional success value).
If the command times out, a warning Is reported And the Exit status Is 124. Some Windows commands Return out-Of-range status values (e.g., -1) And so only the bottom 16 bits Of the value are used.
If intern = False, wait = True, show.output.On.console = True the 'stdout’ and ‘stderr’ (unless ignore.stdout = TRUE or ignore.stderr = TRUE) output from a command that is a ‘console application’ should appear in the R console (Rgui) or the window running R (Rterm).
Not all Windows executables properly respect redirection of output, Or may only do so from a console application such as Rterm And Not from Rgui For example, 'fc.exe’ was among these in the past, but we have had more success recently.
String)Create a new temporary work directory environment for the code
the work directory path will be restore to previous work directory when the generated temporary work directory has been close and disposed
| Name | Type | Description |
|---|---|---|
dir | String | - |
Object, Environment)Vectorized hash/hmac functions
| Name | Type | Description |
|---|---|---|
x | Object | character vector, raw vector or connection object. |
env | Environment | - |
Debug an Expression
apply for debug in Visual Studio, like a script breakpoint
| Name | Type | Description |
|---|---|---|
expr | Expression | any interpreted R expression. |
env | Environment | - |
Pause the current console program.
Data Sets
Loads specified data sets, or list the available data sets.
Currently, four formats of data files are supported:
- files ending ‘.R’ or ‘.r’ are source()d in, with the R working directory changed temporarily to the directory containing the respective file. (data ensures that the utils package is attached, in case it had been run via utils::data.)
- files ending ‘.RData’ or ‘.rda’ are load()ed.
- files ending ‘.tab’, ‘.txt’ or ‘.TXT’ are read using read.table(..., header = TRUE, as.is=FALSE), and hence result in a data frame.
- files ending ‘.csv’ or ‘.CSV’ are read using read.table(..., header = TRUE, sep = ";", as.is=FALSE), and also result in a data frame.
If more than one matching file name is found, the first on this list is used. (Files with extensions ‘.txt’, ‘.tab’ or ‘.csv’ can be compressed, with or without further extension ‘.gz’, ‘.bz2’ or ‘.xz’.)
The data sets to be loaded can be specified as a set of character strings or names, or as the character vector list, or as both.
For each given data set, the first two types (‘.R’ or ‘.r’, and ‘.RData’ or ‘.rda’ files) can create several variables in the load environment, which might all be named differently from the data set. The third and fourth types will always result in the creation of a single variable with the same name (without extension) as the data set.
If no data sets are specified, data lists the available data sets. It looks for a new-style data index in the ‘Meta’ or, if this is not found, an old-style ‘00Index’ file in the ‘data’ directory of each specified package, and uses these files to prepare a listing. If there is a ‘data’ area but no index, available data files for loading are computed and included in the listing, and a warning is given: such packages are incomplete. The information about available data sets is returned in an object of class "packageIQR". The structure of this class is experimental. Where the datasets have a different name from the argument that should be used to retrieve them the index will have an entry like beaver1 (beavers) which tells us that dataset beaver1 can be retrieved by the call data(beaver).
If lib.loc and package are both NULL (the default), the data sets are searched for in all the currently loaded packages then in the ‘data’ directory (if any) of the current working directory.
If lib.loc = NULL but package is specified as a character vector, the specified package(s) are searched for first amongst loaded packages and then in the default library/ies (see .libPaths).
If lib.loc is specified (and not NULL), packages are searched for in the specified library/ies, even if they are already loaded from another library.
To just look in the ‘data’ directory of the current working directory, set package = character(0) (and lib.loc = NULL, the default).
| Name | Type | Description |
|---|---|---|
x | Object | literal character strings Or names. |
package | String() | a character vector giving the package(s) to look in for data sets, or NULL. By Default, all packages in the search path are used, then the 'data’ subdirectory (if present) of the current working directory. |
lib_loc | String | a character vector of directory names of R libraries, or NULL. The default value of NULL corresponds to all libraries currently known. |
env | Environment | - |
| Name | Type | Description |
|---|---|---|
env | Environment | - |
name | String | - |
lib_pkgdir | IFileSystemEnvironment | the folder path of the given installed package module |
hit | Boolean | - |
Find Names of R System Files
Finds the full file names of files in packages etc.
do not add extension suffix name for csv data set due to the reason of csv file extension suffix will be removed automatically in the progress of R compile the data file into package file.
| Name | Type | Description |
|---|---|---|
fileName | String | - |
package | String | a character String With the name Of a Single package. An Error occurs If more than one package name Is given. |
env | Boolean | - |
this function maybe returns a clr stream object if the required file is inside an in-memory zip archive virtual filesystem.
loading a DESCRIPTION file
| Name | Type | Description |
|---|---|---|
package | String | loading current package if the parameter is nothing |
a list object that contains the meta data of the package descirption information. details data members see the clr object: DESCRIPTION.
get current system time
create the time span value based on the given time ticks
| Name | Type | Description |
|---|---|---|
x | Object | - |
Create a Skeleton for a New Source Package
package.skeleton automates some of the setup for a new source package. It creates directories, saves functions, data, and R code files to appropriate places, and creates skeleton help files and a ‘Read-and-delete-me’ file describing further steps in packaging.
The arguments list, environment, and code_files provide alternative ways to initialize the package. If code_files is supplied, the files so named will be sourced to form the environment, then used to generate the package skeleton. Otherwise list defaults to the objects in environment (including those whose names start with .), but can be supplied to select a subset of the objects in that environment.
Stubs of help files are generated for functions, data objects, And S4 classes And methods, using the prompt, promptClass, And promptMethods functions. If an object from another package Is intended to be imported And re-exported without changes, the promptImport function should be used after package.skeleton to generate a simple help file linking to the original one.
The package sources are placed In subdirectory name Of path. If code_files Is supplied, these files are copied; otherwise, objects will be dumped into individual source files. The file names In code_files should have suffix ".R" And be In the current working directory.
The filenames created For source And documentation Try To be valid For all OSes known To run R. Invalid characters are replaced by , invalid names are preceded by zz, names are converted To lower Case (To avoid Case collisions On Case-insensitive file systems) And Finally the converted names are made unique by make.unique(sep = ""). This can be done For code And help files but Not data files (which are looked For by name). Also, the code And help files should have names starting With an ASCII letter Or digit, And this Is checked And If necessary z prepended. Functions with names starting with a dot are placed in file 'R/name-internal.R’. When you are done, delete the 'Read-and-delete-me’ file, as it should not be distributed.
| Name | Type | Description |
|---|---|---|
name | String | character string: the package name and directory name for your package. Must be a valid package name. |
path | String | path to put the package directory in. |
force | Boolean | If False will Not overwrite an existing directory. |
code_files | String() | a character vector with the paths to R code files to build the package around. See ‘Details’. |
encoding | String | optionally a character string with an encoding for an optional Encoding: line in ‘DESCRIPTION’ when non-ASCII characters will be used; typically one of "latin1", "latin2", or "UTF-8"; see the WRE manual. |
list | list | character vector naming the R objects to put in the package. Usually, at most one of list, environment, or code_files will be supplied. See ‘Details’. |
environment | Environment | an environment where objects are looked for. See ‘Details’. |
Used for its side-effects.
String, Object, Boolean, Boolean, Boolean, String, String, Boolean)Extract or List Zip Archives
Extract files from or list a zip archive.
The default internal method is a minimal implementation, principally designed for Windows' users to be able to unpack Windows binary packages without external software. It does not (for example) support Unicode filenames as introduced in zip 3.0: for that use unzip = "unzip" with unzip 6.00 or later. It does have some support for bzip2 compression and > 2GB zip files (but not >= 4GB files pre-compression contained in a zip file: like many builds of unzip it may truncate these, in R's case with a warning if possible). If unzip specifies a program, the format of the dates listed with list = TRUE is unknown (on Windows it can even depend on the current locale) and the return values could be NA or expressed in the wrong time zone or misinterpreted (the latter being far less likely as from unzip 6.00). File times in zip files are stored in the style of MS-DOS, as local times to an accuracy of 2 seconds. This is not very useful when transferring zip files between machines (even across continents), so we chose not to restore them by default.
| Name | Type | Description |
|---|---|---|
zipfile | String | The pathname of the zip file: tilde expansion (see path.expand) will be performed. |
files | Object | A character vector of recorded filepaths to be extracted: the default is to extract all files. |
list | Boolean | If TRUE, list the files and extract none. The equivalent of unzip -l. |
overwrite | Boolean | If TRUE, overwrite existing files (the equivalent of unzip -o), otherwise ignore such files (the equivalent of unzip -n). |
junkpaths | Boolean | If TRUE, use only the basename of the stored filepath when extracting. The equivalent of unzip -j. |
exdir | String | The directory to extract files to (the equivalent of unzip -d). It will be created if necessary. |
unzip | String | The method to be used. An alternative is to use getOption("unzip"), which on a Unix-alike may be set to the path to a unzip program. |
setTimes | Boolean | logical. For the internal method only, should the file times be set based on the times in the zip file? (NB: this applies to included files, not to directories.) |
If list = TRUE, a data frame with columns Name (character) Length (the size of the uncompressed file, numeric) and Date (of class "POSIXct"). Otherwise for the "internal" method, a character vector of the filepaths extracted to, invisibly.
Create Zip Archives
A wrapper for an external zip command to create zip archives.
On a Unix-alike, the default for zip will by default use the value of R_ZIPCMD, which is set in ‘etc/Renviron’ if an unzip command was found during configuration. On Windows, the default relies on a zip program (for example that from Rtools) being in the path.
The default for flags is that appropriate for zipping up a directory tree in a portable way: see the system-specific help for the zip command for other possibilities.
Argument extras can be used to specify -x or -i followed by a list of filepaths to exclude or include. Since extras will be treated as if passed to system, if the filepaths contain spaces they must be quoted e.g. by shQuote.
| Name | Type | Description |
|---|---|---|
zipfile | String | The pathname of the zip file: tilde expansion (see path.expand) will be performed. |
files | Object | A character vector of recorded filepaths to be included. |
flags | String | A character string of flags to be passed to the command: see ‘Details’. |
extras | String | An optional character vector: see ‘Details’. |
zip | Object | A character string specifying the external command to be used. |
env | Environment | - |
The status value returned by the external command, invisibly.
Object, Environment)send task message to the parent node
| Name | Type | Description |
|---|---|---|
x | Object | - |
env | Environment | - |