Learn R Programming

⚠️There's a newer version (2.12.3) of this package.Take me there.

R.utils (version 2.12.2)

Various Programming Utilities

Description

Utility functions useful when programming and developing R packages.

Copy Link

Version

Install

install.packages('R.utils')

Monthly Downloads

137,448

Version

2.12.2

License

LGPL (>= 2.1)

Issues

Pull Requests

Stars

Forks

Last Published

November 11th, 2022

Functions in R.utils (2.12.2)

Java

Static class for Java related methods
FileProgressBar

A progress bar that sets the size of a file accordingly
Non-documented objects

Non-documented objects
NullVerbose

A Verbose class ignoring everything
LComments

The LComments class
Arguments

Static class to validate and process arguments
Options

The Options class
MultiVerbose

A Verbose class ignoring everything
GString

Character string with advanced substitutions
Assert

The Assert class
Verbose

Class to writing verbose messages to a connection or file
ProgressBar

Provides text based counting progress bar
R.utils-package

Package R.utils
SmartComments

Abstract class SmartComments
VComments

The VComments class
TimeoutException

TimeoutException represents timeout errors
Sys.readlink2

Read File Symbolic Links (also on Windows)
TextStatusBar

A status bar at the R prompt that can be updated
System

Static class to query information about the system
as.character.ProgressBar

Gets a string description of the progress bar
as.list.MultiVerbose

Gets a list of Verbose objects
as.character.Options

Returns a character string version of this object
Settings

Class for applicational settings
as.double.Verbose

Gets a numeric value of this object
as.character.Verbose

Returns a character string version of this object
as.list.Options

Gets a list representation of the options
addFinalizerToLast

Modifies .Last() to call 'finalizeSession()
as.character.GString

Gets the processed character string
as.logical.Verbose

Gets a logical value of this object
Java$asByte

Converts a numeric to a Java byte
captureOutput

Evaluate an R expression and captures the output
callHooks

Call hook functions by hook name
Java$asInt

Converts an numeric to a Java integer
capitalize

Capitalizes/decapitalizes each character string in a vector
Java$asLong

Converts a numeric to a Java long
cmdArgs

Simple access to parsed command-line arguments
callHooks.function

Call hook functions
cat.Verbose

Concatenates and prints objects if above threshold
compile.SmartComments

Preprocess a vector of code lines
capture.Verbose

Captures output of a function
compressFile

Compressing and decompressing files
compressPDF

Compresses a PDF (into a new PDF)
Java$asShort

Converts a numeric to a Java short
cmdArgsCall

Calls an R function passing command-line arguments
colClasses

Creates a vector of column classes used for tabular reading
dataFrame

Allocates a data frame with given column classes
commandArgs

Extract command-line arguments
copyFile

Copies a file atomically
attachLocally.list

Assigns an objects elements locally
convertComment.SmartComments

Converts a single smart comment to R code
detachPackage

Detaches packages by name
dimNA< -

Sets the dimension of an object with the option to infer one dimension automatically
createWindowsShortcut

Creates a Microsoft Windows Shortcut (.lnk file)
System$currentTimeMillis

Get the current time in milliseconds
Assert$check

Static method asserting that a generic condition is true
countLines

Counts the number of lines in a text file
displayCode

Displays the contents of a text file with line numbers and more
cleanup.FileProgressBar

Removes the progress file for a file progress bar
createFileAtomically

Creates a file atomically
equals.Verbose

Checks if this object is equal to another
extract.array

Extract a subset of an array, matrix or a vector with unknown dimensions
file.info2

Extract File Information (acknowledging symbolic file links also on Windows)
convertComment.VComments

Converts a verbose comment to R code
copyDirectory

Copies a directory
createLink

Creates a link to a file or a directory
doCall

Executes a function call with option to ignore unused arguments
downloadFile.character

Downloads a file
env

Creates a new environment, evaluates an expression therein, and returns the environment
fileAccess

Checks the permission of a file or a directory
System$findGhostscript

Searches for a Ghostview executable on the current system
egsub

Global substitute of expression using regular expressions
filePath

Construct the path to a file from components and expands Windows Shortcuts along the pathname from root to leaf
equals.Options

Checks if this object is equal to another Options object
finalizeSession

Function to call for finalizing the R session
findFiles

Finds one or several files in multiple directories
evaluate.GString

Parses and evaluates a GString
gcDLLs

Identifies and removes DLLs of packages already unloaded
gcat

Parses, evaluates and outputs a GString
draw.density

Draws a density curve
GString$getBuiltinRversion

Gets the current R version
getAbsolutePath

Gets the absolute pathname string
eget

Gets a variable by name
Settings$findSettings

Searches for the settings file in one or several directories
enter.Verbose

Writes a message and indents the following output
getBarString.ProgressBar

Gets the progress bar string to be displayed
GString$getBuiltinTime

Gets the current time
GString$getBuiltinUsername

Gets the username of the user running R
System$findGraphicsDevice

Searches for a working PNG device
findSourceTraceback

Finds all 'srcfile' objects generated by source() in all call frames
Arguments$getVector

Validates a vector
Arguments$getVerbose

Coerces to Verbose object
GString$getBuiltinPid

Gets the process id of the current R session
Arguments$getIndices

Coerces to a integer vector and validates
GString$getBuiltinDate

Gets the current date
GString$getBuiltinDatetime

Gets the current date and time
increase.ProgressBar

Increases (steps) progress bar
Arguments$getInstanceOf

Gets an instance of the object that is of a particular class
Arguments$getDoubles

Coerces to a double vector and validates
Arguments$getEnvironment

Gets an existing environment
Arguments$getLogicals

Coerces to a logical vector and validates
Arguments$getCharacters

Coerces to a character vector and validates
Assert$inheritsFrom

Static method asserting that an object inherits from of a certain class
GString$getBuiltinRhome

Gets the path where R is installed
Arguments$getRegularExpression

Gets a valid regular expression pattern
getLeaves.Options

Gets all (non-list) options in a flat list
Arguments$getIntegers

Coerces to a integer vector and validates
evaluate.Verbose

Evaluates a function and prints its results if above threshold
getMessage.TimeoutException

Gets the message of the exception
exit.Verbose

Writes a message and unindents the following output
getLabel.TextStatusBar

Gets the current value of a label
isFile

Checks if the file specification is a file
flush.TextStatusBar

Flushes the output
getLoadedPathname.Settings

Gets the pathname of the settings file loaded
Arguments$getNumerics

Coerces to a numeric vector and validates
getOption.Options

Gets an option
getParent

Gets the string of the parent specified by this pathname
getRelativePath

Gets the relative pathname relative to a directory
System$getUsername

Retrieves the name of the user running R
getRaw.GString

Gets the unprocessed GString
format.binmode

Converts a binary/octal/hexadecimal number into a string
Assert$isMatrix

Static method asserting that an object is a matrix
getThreshold.Verbose

Gets current verbose threshold
isReplicated

Identifies all entries with replicated values
GString$getVariableValue

Gets a variable value given a name and attributes
isDone.ProgressBar

Checks if progress bar is completed
getTimestampFormat.Verbose

Gets the default timestamp format
GString$getBuiltinHostname

Gets the hostname of the system running R
intToBin

Converts an integer to a binary/octal/hexadecimal number
intervalsToSeq.matrix

Generates a vector of indices from a matrix of intervals
isEof.connection

Checks if the current file position for a connection is at the 'End of File'
header.Verbose

Writes a header
Arguments$getWritablePathname

Gets a writable pathname
GString$getBuiltinOs

Gets the operating system of the running machine
gstring

Parses and evaluates a GString into a regular string
hpaste

Concatenating vectors into human-readable strings
isModified.Settings

Checks if settings has been modified compared to whats on file
Java$readShort

Reads a Java formatted short (16 bits) from a connection
Assert$isScalar

Static method asserting that an object is a single value
readTable

Reads a file in table format
insert

Insert values to a vector at certain positions
isOn.NullVerbose

Checks if the output is on
reassignInPackage

Re-assigns a new value to an existing object in a loaded package
installPackages

Install R packages by name or URL
loadObject

Method to load object from a file or a connection
isOn.Verbose

Checks if the output is on
removeDirectory

Removes a directory
Arguments$getFilename

Gets and validates a filename
System$getHostname

Retrieves the computer name of the current host
isOpen.character

Checks if there is an open connection to a file
Arguments$getReadablePathname

Gets a readable pathname
isVisible.Verbose

Checks if a certain verbose level will be shown or not
Assert$isVector

Static method asserting that an object is a vector
Arguments$getReadablePathnames

Gets a readable pathname
loadToEnv

Method to load objects to a new environment
isZero

Checks if a value is (close to) zero or not
setThreshold.Verbose

Sets verbose threshold
lastModified

Gets the time when the file was last modified
setTicks.ProgressBar

Sets values for which ticks should be visible
less.Verbose

Creates a cloned instance with a higher threshold
mout

Miscellaneous functions for outputting via message()
isVisible.NullVerbose

Checks if a certain verbose level will be shown or not
withOptions

Evaluate an R expression with options set temporarily
hasOption.Options

Checks if an option exists
moveInSearchPath

Moves a environment in the search path to another position
withRepos

Evaluate an R expression with repositories set temporarily
writeRaw.Verbose

Writes objects if above threshold
hasUrlProtocol

Checks if one or several pathnames has a URL protocol
listDirectory

Gets the file names in the directory
hsize

Convert byte sizes into human-readable byte sizes
patchCode

Patches installed and loaded packages and more
loadAnywhere.Settings

Loads settings from file
popBackupFile

Drops a backup suffix from the backup pathname
nbrOfOptions.Options

Gets the number of options set
printWarnings.Verbose

Outputs any warnings recorded
off.Verbose

Turn off the output
isPackageInstalled

Checks if a package is installed or not
inAnyInterval.numeric

Checks if a set of values are inside one or more intervals
isPackageLoaded

Checks if a package is loaded or not
Java$writeShort

Writes a short (16 bits) to a connection in Java format
printf

C-style formatted output
mkdirs

Creates a directory including any necessary but nonexistent parent directories
readWindowsShellLink

Reads a Microsoft Windows Shortcut (.lnk file)
newline.TextStatusBar

Writes a newline
more.Verbose

Creates a cloned instance with a lower threshold
onGarbageCollect

Registers a function to be called when the R garbage collector is (detected to be) running
isAbsolutePath

Checks if this pathname is absolute
on.Verbose

Turn on the output
System$openBrowser

Opens an HTML document using the OS default HTML browser
parse.GString

Parses a GString
print.GString

Prints the processed GString
print.Verbose

Prints objects if above threshold
readWindowsShortcut

Reads a Microsoft Windows Shortcut (.lnk file)
saveAnywhere.Settings

Saves settings to file
mpager

A \"pager\" function that outputs to standard error
isDirectory

Checks if the file specification is a directory
Java$readInt

Reads a Java formatted int (32 bits) from a connection
readRdHelp

Reads one or more Rd help files in a certain format
names.Options

Gets the full pathname of all (non-list) options
onSessionExit

Registers a function to be called when the R session finishes
popMessage.TextStatusBar

Adds a message above the status bar
saveObject

Saves an object to a file or a connection
reset.ProgressBar

Reset progress bar
pushBackupFile

Appends a backup suffix to the pathname
isSingle

Identifies all entries that exists exactly once
setOption.Options

Sets an option
isUrl

Checks if one or several pathnames is URLs
popTemporaryFile

Drops a temporary suffix from the temporary pathname
setOption

Sets a option in R
reset.SmartComments

Resets a SmartComments compiler
mapToIntervals.numeric

Maps values to intervals
pushState.Verbose

Pushes the current indentation state of the Verbose object
printf.Verbose

Formats and prints object if above threshold
mergeIntervals.numeric

Merges intervals
readBinFragments

Reads binary data from disjoint sections of a connection or a file
promptAndSave.Settings

Prompt user to save modified settings
Java$readByte

Reads a Java formatted byte (8 bits) from a connection
setDefaultLevel.Verbose

Sets the current default verbose level
setLabel.TextStatusBar

Sets the value of a label
sourceTo

Parses and evaluates code from a file or a connection
seqToHumanReadable

Gets a short human readable string representation of an vector of indices
seqToIntervals

Gets all contiguous intervals of a vector of indices
splitByPattern

Splits a single character string by pattern
shell.exec2

Open a file or URL using Windows File Associations
sourceDirectory

Sources files recursively to either local or global environment
renameFile

Renames a file (or a directory) atomically/safely
newline.Verbose

Writes one or several empty lines
setTimestampFormat.Verbose

Sets the default timestamp format
nullfile

Gets the pathname or a connection to the NULL device on the current platform
resample

Sample values from a set of elements
setLabels.TextStatusBar

Sets new values of given labels
tmpfile

Creates a temporary file with content
systemR

Launches another R process from within R
setMaxValue.ProgressBar

Sets maximum value
tempvar

Gets a unique non-existing temporary variable name
update.ProgressBar

Updates progress bar
stext

Writes text in the margin along the sides of a plot
toCamelCase

Converts a string of words into a merged camel-cased word
str.Options

Prints the structure of the options
update.TextStatusBar

Updates the status bar (visually)
parse.SmartComments

Parses one single smart comment
setValue.ProgressBar

Sets current value
timestamp.Verbose

Writes a timestamp
timestampOn.Verbose

Turns automatic timestamping on and off
withSeed

Evaluate an R expression with a temporarily set random set
System$parseDebian

Parses a string, file or connection for Debian formatted parameters
str.Verbose

Prints the structure of an object if above threshold
pushTemporaryFile

Appends a temporary suffix to the pathname
subplots

Creates a grid of subplots
updateLabels.TextStatusBar

Sets the new values of given labels and updates the status bar
use

Attaches or loads packages
toUrl

Converts a pathname into a URL
queryRCmdCheck

Gets the on R CMD check if the current R session was launched by it
readTableIndex

Reads a single column from file in table format
withSink

Evaluate an R expression while temporarily diverting output
withTimeout

Evaluate an R expression and interrupts it if it takes too long
unwrap.array

Unwrap an array, matrix or a vector to an array of more dimensions
touchFile

Updates the timestamp of a file
withCapture

Evaluates an expression and captures the code and/or the output
update.FileProgressBar

Updates file progress bar
wrap.array

Reshape an array or a matrix by permuting and/or joining dimensions
validate.VComments

Validates the compiled lines
withLocale

Evaluate an R expression with locale set temporarily
writeBinFragments

Writes binary data to disjoint sections of a connection or a file
writeRaw.MultiVerbose

Writes to each of the Verbose objects
writeRaw.NullVerbose

All output methods
whichVector.logical

Identifies TRUE elements in a logical vector
writeDataFrame.data.frame

Writes a data.frame to tabular text file
Java$writeInt

Writes a integer (32 bits) to a connection in Java format
Java$writeByte

Writes a byte (8 bits) to a connection in Java format
Java$readUTF

Reads a Java (UTF-8) formatted string from a connection
reset.VComments

Resets a VComments compiler
ruler.Verbose

Writes a ruler
setProgress.ProgressBar

Sets current progress
setStepLength.ProgressBar

Sets default step length
summary.Verbose

Generates a summary of an object if above threshold
swapXY.density

Swaps x and y coordinates of a density object
useRepos

Sets package repositories
validate.SmartComments

Validates the compiled lines
Java$writeUTF

Writes a string to a connection in Java format (UTF-8)