Version: | 2.15.1 |
Depends: | R (≥ 3.2.0), R.oo (≥ 1.24.0) |
Imports: | digest, R.methodsS3, R.utils, R.cache, stats |
Suggests: | gtools (≥ 3.5.0) |
SuggestsNote: | Recommended: gtools |
Title: | Easy Handling of and Access to Files Organized in Structured Directories |
Author: | Henrik Bengtsson [aut, cre, cph] |
Maintainer: | Henrik Bengtsson <henrikb@braju.com> |
Description: | A file set refers to a set of files located in one or more directories on the file system. This package provides classes and methods to locate, setup, subset, navigate and iterate such sets. The API is designed such that these classes can be extended via inheritance to provide a richer API for special file formats. Moreover, a specific name format is defined such that filenames and directories can be considered to have full names which consists of a name followed by comma-separated tags. This adds additional flexibility to identify file sets and individual files. NOTE: This package's API should be considered to be in an beta stage. Its main purpose is currently to support the aroma.* packages, where it is one of the main core components; if you decide to build on top of this package, please contact the author first. |
License: | LGPL-2.1 | LGPL-3 [expanded from: LGPL (≥ 2.1)] |
URL: | https://github.com/HenrikBengtsson/R.filesets, https://www.aroma-project.org/ |
BugReports: | https://github.com/HenrikBengtsson/R.filesets/issues |
LazyLoad: | TRUE |
NeedsCompilation: | no |
Packaged: | 2024-01-24 16:19:44 UTC; henrik |
Repository: | CRAN |
Date/Publication: | 2024-01-24 17:22:49 UTC |
Package R.filesets
Description
A file set refers to a set of files located in one or more directories on the file system. This package provides classes and methods to locate, setup, subset, navigate and iterate such sets. The API is designed such that these classes can be extended via inheritance to provide a richer API for special file formats. Moreover, a specific name format is defined such that filenames and directories can be considered to have full names which consists of a name followed by comma-separated tags. This adds additional flexibility to identify file sets and individual files. NOTE: This package's API should be considered to be in an beta stage. Its main purpose is currently to support the aroma.* packages, where it is one of the main core components; if you decide to build on top of this package, please contact the author first.
This package should be considered to be in an alpha or beta phase. You should expect the API to be changing over time.
Installation
To install this package, call
install.packages("R.filesets")
.
To get started
To get started, see:
How to cite this package
Please cite references [1] when using this package.
License
The releases of this package is licensed under LGPL version 2.1 or newer.
The development code of the packages is under a private licence (where applicable) and patches sent to the author fall under the latter license, but will be, if incorporated, released under the "release" license above.
Author(s)
Henrik Bengtsson
References
[1] H. Bengtsson, The R.oo package - Object-Oriented Programming with References Using Standard R Code, In Kurt Hornik, Friedrich Leisch and Achim Zeileis, editors, Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003), March 20-22, Vienna, Austria. https://www.r-project.org/conferences/DSC-2003/Proceedings/
Gets and validates tags
Description
Gets and validates tags.
Usage
## Static method (use this):
## Arguments$getTags(..., na.rm=TRUE, collapse=",")
## Don't use the below:
## S3 method for class 'Arguments'
getTags(static, ..., na.rm=TRUE, collapse=",")
Arguments
... |
|
na.rm |
If |
collapse |
A |
Value
Returns a character
string or
character
vector
(iff collapse
is NULL
).
Author(s)
Henrik Bengtsson
See Also
For more information see Arguments
.
The ChecksumFile class
Description
Package: R.filesets
Class ChecksumFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
ChecksumFile
Directly known subclasses:
public abstract static class ChecksumFile
extends GenericDataFile
A ChecksumFile is an object referring to a file that contains a checksum for a corresponding "main" file.
Usage
ChecksumFile(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
create | - | |
getChecksum | - | |
isOld | - | |
readChecksum | Reads the checksum value. | |
validate | Asserts that the checksum matches the checksum of file. | |
Methods inherited from GenericDataFile:
as.character, clone, compareChecksum, copyTo, equals, fromFile, getAttribute, getAttributes, getChecksum, getChecksumFile, getCreatedOn, getDefaultFullName, getExtension, getExtensionPattern, getFileSize, getFileType, getFilename, getFilenameExtension, getLastAccessedOn, getLastModifiedOn, getOutputExtension, getPath, getPathname, gunzip, gzip, hasBeenModified, is.na, isFile, isGzipped, linkTo, readChecksum, renameTo, renameToUpperCaseExt, setAttribute, setAttributes, setAttributesBy, setAttributesByTags, setExtensionPattern, testAttributes, validate, validateChecksum, writeChecksum
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
The ChecksumFileSet class
Description
Package: R.filesets
Class ChecksumFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
ChecksumFileSet
Directly known subclasses:
public static class ChecksumFileSet
extends GenericDataFileSet
An ChecksumFileSet object represents a set of ChecksumFile
s.
Usage
ChecksumFileSet(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
readChecksums | - | |
validate | - | |
Methods inherited from GenericDataFileSet:
[, [[, anyDuplicated, anyNA, append, appendFiles, appendFullNamesTranslator, appendFullNamesTranslatorByNULL, appendFullNamesTranslatorByTabularTextFile, appendFullNamesTranslatorByTabularTextFileSet, appendFullNamesTranslatorBydata.frame, appendFullNamesTranslatorByfunction, appendFullNamesTranslatorBylist, as.character, as.list, byName, byPath, c, clearCache, clearFullNamesTranslator, clone, copyTo, dsApplyInPairs, duplicated, equals, extract, findByName, findDuplicated, getChecksum, getChecksumFileSet, getChecksumObjects, getDefaultFullName, getFile, getFileClass, getFileSize, getFiles, getFullNames, getNames, getOneFile, getPath, getPathnames, getSubdirs, gunzip, gzip, hasFile, indexOf, is.na, names, nbrOfFiles, rep, resetFullNames, setFullNamesTranslator, sortBy, unique, update2, updateFullName, updateFullNames, validate
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
The ColumnNamesInterface class interface
Description
Package: R.filesets
Class ColumnNamesInterface
Interface
~~|
~~+--
ColumnNamesInterface
Directly known subclasses:
GenericTabularFile, TabularTextFile
public abstract class ColumnNamesInterface
extends Interface
Usage
ColumnNamesInterface(...)
Arguments
... |
Not used. |
Fields and Methods
Methods:
clearColumnNamesTranslator | - | |
getColumnNames | Gets the column names. | |
nbrOfColumns | Gets the number of columns. | |
setColumnNames | Sets the column names. | |
setColumnNamesTranslator | - | |
Methods inherited from Interface:
extend, print, uses
Author(s)
Henrik Bengtsson
Deprecated and defunct objects
Description
The following objects are defunct:
None
The following objects are deprecated:
None
The FullNameInterface class interface
Description
Package: R.filesets
Class FullNameInterface
Interface
~~|
~~+--
FullNameInterface
Directly known subclasses:
ChecksumFile, ChecksumFileSet, GenericDataFile, GenericDataFileSet, GenericDataFileSetList, GenericTabularFile, GenericTabularFileSet, RDataFile, RDataFileSet, RdsFile, RdsFileSet, TabularTextFile, TabularTextFileSet
public abstract class FullNameInterface
extends Interface
Usage
FullNameInterface(...)
Arguments
... |
Not used. |
Details
The full name consists of a name followed by optional comma-separated tags.
For instance, the full name of foo,a.2,b
has name foo
with
tags a.2
and b
.
Fields and Methods
Methods:
appendFullNameTranslator | - | |
clearFullNameTranslator | - | |
getFullName | Gets the full name. | |
getName | Gets the name. | |
getTags | Gets the tags. | |
hasTag | - | |
hasTags | Checks whether the fullname contains a given set of tag(s). | |
setFullName | Sets the full name. | |
setFullNameTranslator | - | |
setName | Sets the name part of the fullname. | |
setTags | Sets the tags. | |
Methods inherited from Interface:
extend, print, uses
Author(s)
Henrik Bengtsson
Examples
# Setup a file set
path <- system.file("R", package="R.filesets")
ds <- GenericDataFileSet$byPath(path)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data set
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Path of data set:\n")
print(getPath(ds))
cat("Fullname of data set:\n")
print(getFullName(ds))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Pathnames:\n")
print(getPathnames(ds))
cat("Filenames:\n")
print(sapply(ds, getFilename))
cat("Default fullnames:\n")
print(getFullNames(ds))
cat("Extensions:\n")
print(sapply(ds, getExtension))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Translation of data file names
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Translate fullnames to lower case
setFullNamesTranslator(ds, function(names, ...) tolower(names))
cat("Lower-case fullnames:\n")
print(getFullNames(ds))
# Append a translator that reverse the order of the letters
revStr <- function(names, ...) {
names <- strsplit(names, split="", fixed=TRUE)
names <- lapply(names, FUN=rev)
names <- sapply(names, FUN=paste, collapse="")
names
}
appendFullNamesTranslator(ds, revStr)
cat("Reversed lower-case fullnames:\n")
fn3 <- getFullNames(ds)
print(fn3)
# Alternative for setting up a sequence of translators
setFullNamesTranslator(ds, list(function(names, ...) tolower(names), revStr))
cat("Reversed lower-case fullnames:\n")
fn3b <- getFullNames(ds)
print(fn3b)
stopifnot(identical(fn3b, fn3))
# Reset
clearFullNamesTranslator(ds)
cat("Default fullnames (after resetting):\n")
print(getFullNames(ds))
The abstract GenericDataFile class
Description
Package: R.filesets
Class GenericDataFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
Directly known subclasses:
ChecksumFile, GenericTabularFile, RDataFile, RdsFile, TabularTextFile
public abstract static class GenericDataFile
extends FullNameInterface
A GenericDataFile is an object referring to a data file on a file system.
Note that this class is abstract and can not be instantiated, but
instead you have to use one of the subclasses or the generic
*fromFile()
method.
Usage
GenericDataFile(filename=NULL, path=NULL, mustExist=!is.na(filename), ...,
.onUnknownArgs=c("error", "warning", "ignore"))
Arguments
filename |
The filename of the file. |
path |
An optional path to the file. |
mustExist |
If |
... |
Not used. |
.onUnknownArgs |
A |
Fields and Methods
Methods:
compareChecksum | Compares the file checksum with the value of the checksum file. | |
equals | Checks if a file equals another. | |
getChecksum | Gets the checksum of a file. | |
getChecksumFile | - | |
getExtension | Gets the filename extension. | |
getFileSize | Gets the size of a file. | |
getFileType | Gets the file type of a file. | |
getFilename | Gets the filename of the file. | |
getPath | Gets the path (directory) of the file. | |
getPathname | Gets the pathname of the file. | |
is.na | - | |
isFile | Checks if this is an existing file. | |
validateChecksum | Asserts that the file checksum matches the one of the checksum file. | |
writeChecksum | Write the file checksum to a checksum file. | |
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Filename convention
The filename of an GenericDataFile
is structured as follows:
- filename
:
"sample001,a,b,c.CEL"
(this follows the R convention, but not the Unix convention)- fullname
:
"sample001,a,b,c"
- name
:
"sample001"
- tags
:
c("a", "b", "c")
- extension
:
"CEL"
Author(s)
Henrik Bengtsson
See Also
An object of this class is typically part of an GenericDataFileSet
.
Defines a GenericDataFile from a pathname
Description
Defines a GenericDataFile from a pathname.
Usage
## Static method (use this):
## GenericDataFile$fromFile(filename, path=NULL, ..., recursive=TRUE, verbose=FALSE,
## .checkArgs=TRUE)
## Don't use the below:
## S3 method for class 'GenericDataFile'
fromFile(static, filename, path=NULL, ..., recursive=TRUE, verbose=FALSE,
.checkArgs=TRUE)
Arguments
filename , path |
The filename and the path to the file. The file must exist, otherwise an exception is thrown. |
... |
Not used. |
recursive |
If TRUE, ... |
verbose |
... |
.checkArgs |
(Internal) If FALSE, validation of file existence and arguments are skipped. |
Value
Returns a GenericDataFile
(or a subclass thereof).
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
The GenericDataFileSet class
Description
Package: R.filesets
Class GenericDataFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
Directly known subclasses:
ChecksumFileSet, GenericTabularFileSet, RDataFileSet, RdsFileSet, TabularTextFileSet
public static class GenericDataFileSet
extends FullNameInterface
A GenericDataFileSet object represents a set of GenericDataFile
s.
Usage
GenericDataFileSet(files=NULL, tags="*", depth=NULL, ...,
.onUnknownArgs=c("error", "warning", "ignore"))
Arguments
files |
A |
tags |
A |
depth |
An non-negative |
... |
Not used. |
.onUnknownArgs |
A |
Fields and Methods
Methods:
anyDuplicated | - | |
anyNA | - | |
append | - | |
appendFiles | - | |
as.list | - | |
byName | - | |
byPath | - | |
duplicated | - | |
equals | - | |
extract | - | |
getChecksum | - | |
getChecksumFileSet | - | |
getDefaultFullName | - | |
getFile | - | |
getFileClass | - | |
getFileSize | - | |
getFullNames | - | |
getNames | - | |
getOneFile | - | |
getPath | - | |
getPathnames | - | |
gunzip | - | |
gzip | - | |
hasFile | - | |
indexOf | - | |
is.na | - | |
sortBy | - | |
unique | - | |
validate | - | |
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
Examples
# Setup a file set
path <- system.file(package="R.filesets")
ds <- GenericDataFileSet$byPath(path)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data set
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Path of data set:\n")
print(getPath(ds))
cat("Fullname of data set:\n")
print(getFullName(ds))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Data files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat("Pathnames:\n")
print(getPathnames(ds))
cat("Filenames:\n")
print(sapply(ds, getFilename))
cat("Extensions:\n")
print(sapply(ds, getExtension))
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Subsetting
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
n <- length(ds)
ds2 <- extract(ds, 1:n)
print(ds2)
ds3 <- extract(ds, n:1)
print(ds3)
stopifnot(identical(rev(getPathnames(ds3)), getPathnames(ds2)))
idxs <- c(1,2,NA,n,NA)
ds4 <- extract(ds, idxs, onMissing="NA")
print(ds4)
print(getFullNames(ds4))
print(getFiles(ds4))
stopifnot(identical(is.na(idxs), unname(is.na(getPathnames(ds4)))))
Locates and sets up a file set by its name
Description
Locates and sets up a file set by its name, tags, root and sub directories.
Usage
## Static method (use this):
## GenericDataFileSet$byName(name, tags=NULL, subdirs=NULL, paths=NULL, ...,
## verbose=FALSE)
## Don't use the below:
## S3 method for class 'GenericDataFileSet'
byName(static, name, tags=NULL, subdirs=NULL, paths=NULL, ..., verbose=FALSE)
Arguments
name , tags |
The name and the tags of the file set to be located. |
subdirs |
A |
paths |
A |
... |
Not used. |
verbose |
... |
Value
Returns a GenericDataFileSet
.
If not found, an exception is thrown.
Author(s)
Henrik Bengtsson
See Also
Internally, *findByName()
is used to locate the data set,
and *byPath()
to then set it up.
For more information see GenericDataFileSet
.
Defines a GenericDataFileSet by searching for files in a directory
Description
Defines a GenericDataFileSet by searching for files in a directory.
Usage
## Static method (use this):
## GenericDataFileSet$byPath(path=NULL, pattern=NULL, private=FALSE, recursive=FALSE,
## depth=0L, fileClass=getFileClass(static), ..., .validate=FALSE, verbose=FALSE)
## Don't use the below:
## S3 method for class 'GenericDataFileSet'
byPath(static, path=NULL, pattern=NULL, private=FALSE, recursive=FALSE, depth=0L,
fileClass=getFileClass(static), ..., .validate=FALSE, verbose=FALSE)
Arguments
path |
The directory where to search for files. |
pattern |
The filename pattern for match files.
If |
private |
If |
recursive |
If |
... |
Optional arguments passed to the constructor of the static (calling) class. |
Value
Returns an GenericDataFileSet
object.
Reserved filenames
Note that files with names starting with a period .
are not
searched for. Such files are considered "private" and have to be
included explicitly, if wanted.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Locates all file sets that match the requested name
Description
Locates all file sets that match the requested name, tags, and sub directories, in any of the root paths.
Usage
## Static method (use this):
## GenericDataFileSet$findByName(name, tags=NULL, subdirs=NULL, paths=NULL,
## firstOnly=TRUE, mustExist=FALSE, ..., verbose=FALSE)
## Don't use the below:
## S3 method for class 'GenericDataFileSet'
findByName(static, name, tags=NULL, subdirs=NULL, paths=NULL, firstOnly=TRUE,
mustExist=FALSE, ..., verbose=FALSE)
Arguments
name , tags |
The name and the tags of the file set to be located. |
subdirs |
A |
paths |
A |
firstOnly |
If |
mustExist |
If |
... |
Not used. |
verbose |
... |
Value
Returns a character
vector
of paths.
If no file sets were found, NULL
is returned.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
The GenericDataFileSetList class
Description
Package: R.filesets
Class GenericDataFileSetList
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSetList
Directly known subclasses:
public static class GenericDataFileSetList
extends FullNameInterface
A GenericDataFileSetList object represents a list of
GenericDataFileSet
s.
Usage
GenericDataFileSetList(dsList=list(), tags="*", ..., allowDuplicates=TRUE,
.setClass="GenericDataFileSet")
Arguments
dsList |
A single or a |
tags |
|
... |
Not used. |
allowDuplicates |
If |
.setClass |
A |
Fields and Methods
Methods:
as | - | |
as.GenericDataFileSetList | - | |
as.list | - | |
getFileList | - | |
getFullNames | - | |
getNames | - | |
getSet | - | |
getSets | - | |
indexOf | - | |
length | - | |
nbrOfSets | - | |
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
Examples
# Setup a file set
path1 <- system.file(package="R.filesets")
ds1 <- GenericDataFileSet$byPath(path1)
path2 <- system.file(package="R.utils")
ds2 <- GenericDataFileSet$byPath(path2)
dsl <- GenericDataFileSetList(list(ds1, ds2), tags=c("*", "CustomTag"))
print(dsl)
df <- as.data.frame(dsl)
print(df)
print(df["DESCRIPTION","R.filesets"])
The abstract GenericTabularFile class
Description
Package: R.filesets
Class GenericTabularFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
ColumnNamesInterface
~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~+--
GenericTabularFile
Directly known subclasses:
TabularTextFile
public abstract static class GenericTabularFile
extends ColumnNamesInterface
A TabularTextFile is an object referring to a tabular text file on a file system containing data in a tabular format. Methods for reading all or a subset of the tabular data exist.
Usage
GenericTabularFile(..., .verify=TRUE, verbose=FALSE)
Arguments
... |
Arguments passed to |
.verify , verbose |
(Internal only) If |
Fields and Methods
Methods:
dim | - | |
extractMatrix | - | |
head | - | |
nbrOfColumns | - | |
nbrOfRows | - | |
readColumns | - | |
readDataFrame | - | |
tail | - | |
writeColumnsToFiles | - | |
Methods inherited from ColumnNamesInterface:
appendColumnNamesTranslator, appendColumnNamesTranslatorByNULL, appendColumnNamesTranslatorBycharacter, appendColumnNamesTranslatorByfunction, appendColumnNamesTranslatorBylist, clearColumnNamesTranslator, clearListOfColumnNamesTranslators, getColumnNames, getColumnNamesTranslator, getDefaultColumnNames, getListOfColumnNamesTranslators, nbrOfColumns, setColumnNames, setColumnNamesTranslator, setListOfColumnNamesTranslators, updateColumnNames
Methods inherited from GenericDataFile:
as.character, clone, compareChecksum, copyTo, equals, fromFile, getAttribute, getAttributes, getChecksum, getChecksumFile, getCreatedOn, getDefaultFullName, getExtension, getExtensionPattern, getFileSize, getFileType, getFilename, getFilenameExtension, getLastAccessedOn, getLastModifiedOn, getOutputExtension, getPath, getPathname, gunzip, gzip, hasBeenModified, is.na, isFile, isGzipped, linkTo, readChecksum, renameTo, renameToUpperCaseExt, setAttribute, setAttributes, setAttributesBy, setAttributesByTags, setExtensionPattern, testAttributes, validate, validateChecksum, writeChecksum
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
See Also
An object of this class is typically part of an
GenericTabularFileSet
.
The GenericTabularFileSet class
Description
Package: R.filesets
Class GenericTabularFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
GenericTabularFileSet
Directly known subclasses:
TabularTextFileSet
public static class GenericTabularFileSet
extends GenericDataFileSet
An GenericTabularFileSet object represents a set of
GenericTabularFile
s.
Usage
GenericTabularFileSet(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
extractMatrix | - | |
Methods inherited from GenericDataFileSet:
[, [[, anyDuplicated, anyNA, append, appendFiles, appendFullNamesTranslator, appendFullNamesTranslatorByNULL, appendFullNamesTranslatorByTabularTextFile, appendFullNamesTranslatorByTabularTextFileSet, appendFullNamesTranslatorBydata.frame, appendFullNamesTranslatorByfunction, appendFullNamesTranslatorBylist, as.character, as.list, byName, byPath, c, clearCache, clearFullNamesTranslator, clone, copyTo, dsApplyInPairs, duplicated, equals, extract, findByName, findDuplicated, getChecksum, getChecksumFileSet, getChecksumObjects, getDefaultFullName, getFile, getFileClass, getFileSize, getFiles, getFullNames, getNames, getOneFile, getPath, getPathnames, getSubdirs, gunzip, gzip, hasFile, indexOf, is.na, names, nbrOfFiles, rep, resetFullNames, setFullNamesTranslator, sortBy, unique, update2, updateFullName, updateFullNames, validate
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
Non-documented objects
Description
This page contains aliases for all "non-documented" objects that
R CMD check
detects in this package.
Almost all of them are generic functions that have specific
document for the corresponding method coupled to a specific class.
Other functions are re-defined by setMethodS3()
to
default methods. Neither of these two classes are non-documented
in reality.
The rest are deprecated methods.
Author(s)
Henrik Bengtsson
The RDataFile class
Description
Package: R.filesets
Class RDataFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
RDataFile
Directly known subclasses:
public abstract static class RDataFile
extends GenericDataFile
An RDataFile represents a binary file containing R objects
saved using the save
() function.
Usage
RDataFile(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
loadObject | - | |
loadToEnv | - | |
Methods inherited from GenericDataFile:
as.character, clone, compareChecksum, copyTo, equals, fromFile, getAttribute, getAttributes, getChecksum, getChecksumFile, getCreatedOn, getDefaultFullName, getExtension, getExtensionPattern, getFileSize, getFileType, getFilename, getFilenameExtension, getLastAccessedOn, getLastModifiedOn, getOutputExtension, getPath, getPathname, gunzip, gzip, hasBeenModified, is.na, isFile, isGzipped, linkTo, readChecksum, renameTo, renameToUpperCaseExt, setAttribute, setAttributes, setAttributesBy, setAttributesByTags, setExtensionPattern, testAttributes, validate, validateChecksum, writeChecksum
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
See Also
An object of this class is typically part of an RDataFileSet
.
The RDataFileSet class
Description
Package: R.filesets
Class RDataFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
RDataFileSet
Directly known subclasses:
public static class RDataFileSet
extends GenericDataFileSet
An RDataFileSet object represents a set of RDataFile
:s.
Usage
RDataFileSet(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
byPath | - | |
Methods inherited from GenericDataFileSet:
[, [[, anyDuplicated, anyNA, append, appendFiles, appendFullNamesTranslator, appendFullNamesTranslatorByNULL, appendFullNamesTranslatorByTabularTextFile, appendFullNamesTranslatorByTabularTextFileSet, appendFullNamesTranslatorBydata.frame, appendFullNamesTranslatorByfunction, appendFullNamesTranslatorBylist, as.character, as.list, byName, byPath, c, clearCache, clearFullNamesTranslator, clone, copyTo, dsApplyInPairs, duplicated, equals, extract, findByName, findDuplicated, getChecksum, getChecksumFileSet, getChecksumObjects, getDefaultFullName, getFile, getFileClass, getFileSize, getFiles, getFullNames, getNames, getOneFile, getPath, getPathnames, getSubdirs, gunzip, gzip, hasFile, indexOf, is.na, names, nbrOfFiles, rep, resetFullNames, setFullNamesTranslator, sortBy, unique, update2, updateFullName, updateFullNames, validate
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
The RdsFile class
Description
Package: R.filesets
Class RdsFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
RdsFile
Directly known subclasses:
public abstract static class RdsFile
extends GenericDataFile
An RdsFile represents a binary file containing an R object
saved using the saveRDS
() function.
Usage
RdsFile(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
loadObject | - | |
loadRDS | - | |
Methods inherited from GenericDataFile:
as.character, clone, compareChecksum, copyTo, equals, fromFile, getAttribute, getAttributes, getChecksum, getChecksumFile, getCreatedOn, getDefaultFullName, getExtension, getExtensionPattern, getFileSize, getFileType, getFilename, getFilenameExtension, getLastAccessedOn, getLastModifiedOn, getOutputExtension, getPath, getPathname, gunzip, gzip, hasBeenModified, is.na, isFile, isGzipped, linkTo, readChecksum, renameTo, renameToUpperCaseExt, setAttribute, setAttributes, setAttributesBy, setAttributesByTags, setExtensionPattern, testAttributes, validate, validateChecksum, writeChecksum
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
See Also
An object of this class is typically part of an RdsFileSet
.
The RdsFileSet class
Description
Package: R.filesets
Class RdsFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
RdsFileSet
Directly known subclasses:
public static class RdsFileSet
extends GenericDataFileSet
An RdsFileSet object represents a set of RdsFile
:s.
Usage
RdsFileSet(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
byPath | - | |
Methods inherited from GenericDataFileSet:
[, [[, anyDuplicated, anyNA, append, appendFiles, appendFullNamesTranslator, appendFullNamesTranslatorByNULL, appendFullNamesTranslatorByTabularTextFile, appendFullNamesTranslatorByTabularTextFileSet, appendFullNamesTranslatorBydata.frame, appendFullNamesTranslatorByfunction, appendFullNamesTranslatorBylist, as.character, as.list, byName, byPath, c, clearCache, clearFullNamesTranslator, clone, copyTo, dsApplyInPairs, duplicated, equals, extract, findByName, findDuplicated, getChecksum, getChecksumFileSet, getChecksumObjects, getDefaultFullName, getFile, getFileClass, getFileSize, getFiles, getFullNames, getNames, getOneFile, getPath, getPathnames, getSubdirs, gunzip, gzip, hasFile, indexOf, is.na, names, nbrOfFiles, rep, resetFullNames, setFullNamesTranslator, sortBy, unique, update2, updateFullName, updateFullNames, validate
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
The TabularTextFile class
Description
Package: R.filesets
Class TabularTextFile
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFile
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
ColumnNamesInterface
~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~+--
GenericTabularFile
~~~~~~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~~~~~~+--
TabularTextFile
Directly known subclasses:
public abstract static class TabularTextFile
extends GenericTabularFile
A TabularTextFile is an object referring to a tabular text file on a file system containing data in a tabular format. Methods for reading all or a subset of the tabular data exist.
Usage
TabularTextFile(..., sep=c("\t", ","), quote="\"", fill=FALSE, skip=0L, columnNames=NA,
commentChar="#", .verify=TRUE, verbose=FALSE)
Arguments
... |
Arguments passed to |
sep |
A |
quote |
A |
fill |
As in |
skip |
As in |
columnNames |
A |
commentChar |
A single |
.verify , verbose |
(Internal only) If |
Fields and Methods
Methods:
getHeader | - | |
nbrOfLines | - | |
nbrOfRows | - | |
readDataFrame | - | |
readLines | - | |
Methods inherited from GenericTabularFile:
[, as.character, dim, extractMatrix, head, nbrOfColumns, nbrOfRows, readColumns, readDataFrame, tail, writeColumnsToFiles
Methods inherited from ColumnNamesInterface:
appendColumnNamesTranslator, appendColumnNamesTranslatorByNULL, appendColumnNamesTranslatorBycharacter, appendColumnNamesTranslatorByfunction, appendColumnNamesTranslatorBylist, clearColumnNamesTranslator, clearListOfColumnNamesTranslators, getColumnNames, getColumnNamesTranslator, getDefaultColumnNames, getListOfColumnNamesTranslators, nbrOfColumns, setColumnNames, setColumnNamesTranslator, setListOfColumnNamesTranslators, updateColumnNames
Methods inherited from GenericDataFile:
as.character, clone, compareChecksum, copyTo, equals, fromFile, getAttribute, getAttributes, getChecksum, getChecksumFile, getCreatedOn, getDefaultFullName, getExtension, getExtensionPattern, getFileSize, getFileType, getFilename, getFilenameExtension, getLastAccessedOn, getLastModifiedOn, getOutputExtension, getPath, getPathname, gunzip, gzip, hasBeenModified, is.na, isFile, isGzipped, linkTo, readChecksum, renameTo, renameToUpperCaseExt, setAttribute, setAttributes, setAttributesBy, setAttributesByTags, setExtensionPattern, testAttributes, validate, validateChecksum, writeChecksum
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
See Also
An object of this class is typically part of an TabularTextFileSet
.
Examples
path <- system.file("exData/dataSetA,original", package="R.filesets")
db <- TabularTextFile("fileA,20100112.dat", path=path)
print(db)
# Read all data
data <- readDataFrame(db)
print(data)
# Read columns 'x', 'y', and 'char'
data <- readDataFrame(db, colClasses=c("(x|y)"="integer", "char"="character"))
print(data)
# Translate column names on the fly
db <- setColumnNamesTranslator(db, function(names, ...) toupper(names))
data <- readDataFrame(db, colClasses=c("(X|Y)"="integer", "CHAR"="character"))
print(data)
The TabularTextFileSet class
Description
Package: R.filesets
Class TabularTextFileSet
Object
~~|
~~+--
FullNameInterface
~~~~~~~|
~~~~~~~+--
GenericDataFileSet
~~~~~~~~~~~~|
~~~~~~~~~~~~+--
GenericTabularFileSet
~~~~~~~~~~~~~~~~~|
~~~~~~~~~~~~~~~~~+--
TabularTextFileSet
Directly known subclasses:
public static class TabularTextFileSet
extends GenericTabularFileSet
An TabularTextFileSet object represents a set of TabularTextFile
s.
Usage
TabularTextFileSet(...)
Arguments
... |
Arguments passed to |
Fields and Methods
Methods:
readDataFrame | - | |
Methods inherited from GenericTabularFileSet:
extractMatrix
Methods inherited from GenericDataFileSet:
[, [[, anyDuplicated, anyNA, append, appendFiles, appendFullNamesTranslator, appendFullNamesTranslatorByNULL, appendFullNamesTranslatorByTabularTextFile, appendFullNamesTranslatorByTabularTextFileSet, appendFullNamesTranslatorBydata.frame, appendFullNamesTranslatorByfunction, appendFullNamesTranslatorBylist, as.character, as.list, byName, byPath, c, clearCache, clearFullNamesTranslator, clone, copyTo, dsApplyInPairs, duplicated, equals, extract, findByName, findDuplicated, getChecksum, getChecksumFileSet, getChecksumObjects, getDefaultFullName, getFile, getFileClass, getFileSize, getFiles, getFullNames, getNames, getOneFile, getPath, getPathnames, getSubdirs, gunzip, gzip, hasFile, indexOf, is.na, names, nbrOfFiles, rep, resetFullNames, setFullNamesTranslator, sortBy, unique, update2, updateFullName, updateFullNames, validate
Methods inherited from FullNameInterface:
appendFullNameTranslator, appendFullNameTranslatorByNULL, appendFullNameTranslatorByTabularTextFile, appendFullNameTranslatorByTabularTextFileSet, appendFullNameTranslatorBycharacter, appendFullNameTranslatorBydata.frame, appendFullNameTranslatorByfunction, appendFullNameTranslatorBylist, clearFullNameTranslator, clearListOfFullNameTranslators, getDefaultFullName, getFullName, getFullNameTranslator, getListOfFullNameTranslators, getName, getTags, hasTag, hasTags, resetFullName, setFullName, setFullNameTranslator, setListOfFullNameTranslators, setName, setTags, updateFullName
Methods inherited from Object:
$, $<-, [[, [[<-, as.character, attach, attachLocally, clearCache, clearLookupCache, clone, detach, equals, extend, finalize, getEnvironment, getFieldModifier, getFieldModifiers, getFields, getInstantiationTime, getStaticInstance, hasField, hashCode, ll, load, names, objectSize, print, save
Author(s)
Henrik Bengtsson
Examples
# Setup a file set consisting of all *.dat tab-delimited files
# in a particular directory
path <- system.file("exData/dataSetA,original", package="R.filesets")
ds <- TabularTextFileSet$byPath(path, pattern="[.]dat$")
print(ds)
# Read column 'y' and a subset of the rows from each of the
# tab-delimited files and combine into a matrix
rows <- c(3:5, 8, 2)
data <- extractMatrix(ds, column="y", colClass="integer", rows=rows)
print(data)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# See also help("readDataFrame.TabularTextFileSet")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# ADVANCED: Translation of fullnames
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fnts <- TabularTextFileSet$byPath(getPath(ds), pattern=",fullnames[.]txt$")
appendFullNamesTranslator(ds, as.list(fnts))
cat("Default fullnames:\n")
print(head(getFullNames(ds, translate=FALSE)))
cat("Translated fullnames:\n")
print(head(getFullNames(ds)))
cat("Default fullnames:\n")
print(getFullNames(ds, translate=FALSE))
cat("Translated fullnames:\n")
print(getFullNames(ds))
Checks whether any of the pathnames are missing
Description
Checks whether any of the pathnames are missing. Note that this only tests the pathnames of files, but it does not test whether the files exists or not.
Usage
## S3 method for class 'GenericDataFileSet'
anyNA(x, ...)
Arguments
... |
Not used. |
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
na.omit
for dropping missing items.
For more information see GenericDataFileSet
.
Appends one data set to an existing one
Description
Appends one data set to an existing one. The fullname of the merged data set is that of the first data set.
Usage
## S3 method for class 'GenericDataFileSet'
append(x, values, ...)
Arguments
values |
The data set to be appended to this data set. |
... |
Additional arguments passed to |
Details
By default, in order to avoid downstream side effects on the data set being appended, each of its file is cloned before being appended.
Value
Returns a merged GenericDataFileSet
of the same class as the
first data set.
Author(s)
Henrik Bengtsson
See Also
To append one or more files, see appendFiles
().
For more information see GenericDataFileSet
.
Appends a list of files to a data set
Description
Appends a list of files to a data set.
Usage
## S3 method for class 'GenericDataFileSet'
appendFiles(this, files, clone=TRUE, ..., .fileClass=getFileClass(this),
.assertSameClass=TRUE, verbose=FALSE)
Arguments
files |
A single |
clone |
If |
... |
Additional arguments passed to |
.fileClass |
A |
.assertSameClass |
If |
verbose |
... |
Details
The files appended must inherit the same class as the first file of the data set, otherwise an exception is thrown.
Value
Returns (invisible) the appended data set (itself).
Author(s)
Henrik Bengtsson
See Also
To append a data set, see append
().
For more information see GenericDataFileSet
.
Returns a short string describing the file
Description
Returns a short string describing the file.
Usage
## S3 method for class 'GenericDataFile'
as.character(x, ...)
Arguments
... |
Not used. |
Value
Returns a character
string.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Returns a short string describing the file set
Description
Returns a short string describing the file set.
Usage
## S3 method for class 'GenericDataFileSet'
as.character(x, ...)
Arguments
... |
Not used. |
Value
Returns a character
string.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Returns the files of the file set
Description
Returns the files of the file set.
Usage
## S3 method for class 'GenericDataFileSet'
as.list(x, useNames=TRUE, ...)
Arguments
... |
Arguments passed to |
useNames |
If |
Value
Returns a list
of files, each of class getFileClass
().
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Compares the file checksum with the value of the checksum file
Description
Compares the file checksum with the value of the checksum file.
Usage
## S3 method for class 'GenericDataFile'
compareChecksum(this, ...)
Arguments
... |
Additional arguments passed to |
Value
Returns TRUE
if the file checksum is identical to the stored value
in the corresponding checksum file, otherwise FALSE
. FALSE
is
also returned if the checksum file does not exist.
An exception is thrown if the file does not exist.
Author(s)
Henrik Bengtsson
See Also
*validateChecksum()
.
*readChecksum()
.
*writeChecksum()
.
*getChecksum()
.
For more information see GenericDataFile
.
Safely copies a file to a new pathname
Description
Safely copies a file to a new pathname.
Usage
## S3 method for class 'GenericDataFile'
copyTo(this, filename=getFilename(this), path=NULL, ...)
Arguments
filename , path |
The filename and the path for the destination file. The default is to use the same filename as the source file. |
... |
Additional arguments passed to |
Details
In order to minimize the risk for corrupt copies, the
copyFile
method of R.utils is used, which
provides several protection against user, system and file errors.
Value
Returns a GenericDataFile
(of the same class as the source file)
referring to the new file copy.
Author(s)
Henrik Bengtsson
See Also
To link to a GenericDataFile
, see *linkTo()
.
To rename a GenericDataFile
, see *renameTo()
.
Internally copyFile
is used.
For more information see GenericDataFile
.
Copies a data set to another directory
Description
Copies a data set to another directory.
Usage
## S3 method for class 'GenericDataFileSet'
copyTo(this, path=NULL, ..., verbose=FALSE)
Arguments
path |
The destination directory. If missing, it is created. |
... |
Additional arguments passed to |
verbose |
... |
Details
Each file is copied safely, but if this method is interrupted, it may results in a data set consisting of fewer than the original data set.
Value
Returns a GenericDataFileSet
consisting the new file copies.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Gets the dimension of data table
Description
Gets the dimension of data table, which is the number of rows and the number of columns.
Usage
## S3 method for class 'GenericTabularFile'
dim(x)
Value
Returns an integer
vector
of length two.
Author(s)
Henrik Bengtsson
See Also
*nbrOfRows()
.
For more information see GenericTabularFile
.
Applies a function to each pair of file in two file sets
Description
Applies a function to each pair of file in two file sets.
Usage
## S3 method for class 'GenericDataFileSet'
dsApplyInPairs(ds1, ds2, FUN, ..., args=list(), skip=FALSE, verbose=FALSE,
.parallel=NULL, .control=NULL)
Arguments
ds1 , ds2 |
|
FUN |
A |
... |
Arguments passed to |
args |
(optional) A named |
skip |
If |
verbose |
See |
Details
WARNING: dsApplyInPairs()
is defunct; instead use
future.apply::future_mapply()
.
Value
Returns a list
.
Author(s)
Henrik Bengtsson
Examples
## Not run:
# - - - - - - - - - - - - - - - - - - - - - - - -
# Setting up a file set
# - - - - - - - - - - - - - - - - - - - - - - - -
path <- system.file(package="R.filesets")
ds <- GenericDataFileSet$byPath(path)
# - - - - - - - - - - - - - - - - - - - - - - - -
# Get the size of each file
# - - - - - - - - - - - - - - - - - - - - - - - -
sizes <- lapply(ds, FUN=getFileSize)
str(sizes)
## End(Not run)
Checks if a file equals another
Description
Checks if a file equals another.
Usage
## S3 method for class 'GenericDataFile'
equals(this, other, ...)
Arguments
other |
The other |
... |
Not used. |
Details
The two files compared are equal if they have the same pathname.
The two files compared are not equal if:
Argument
other
is not aGenericDataFile
, ortheir file sizes differ, or
their file checksums differ.
If none of the above occurs, the two files are considered equal.
Note that subclasses use refined rules.
Value
Returns TRUE
if the file equals the other, otherwise FALSE
.
If FALSE
, attributes are added specifying the pathnames of the two
files compared, and the reason for them being different.
Author(s)
Henrik Bengtsson
See Also
*getFileSize()
.
*getChecksum()
.
For more information see GenericDataFile
.
Extract a subset of the file set
Description
Extract a subset of the file set.
Usage
## S3 method for class 'GenericDataFileSet'
extract(this, files, ..., onMissing=c("NA", "error", "drop", "dropall"),
onDuplicates=c("ignore", "drop", "error"))
Arguments
files |
An |
... |
Not used. |
onMissing |
A |
Value
Returns a GenericDataFileSet
with zero of more
GenericDataFile
:s.
Author(s)
Henrik Bengtsson
See Also
na.omit
for dropping missing files from a fileset.
For more information see GenericDataFileSet
.
Reads one of the columns
Description
Reads one of the columns.
Usage
## S3 method for class 'GenericTabularFile'
extractMatrix(this, column=1L, drop=FALSE, ..., verbose=FALSE)
Arguments
column |
An |
drop |
If |
... |
Additional arguments passed to |
verbose |
Value
Returns a Jx1 matrix
, or if drop=TRUE
a vector
of length J.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericTabularFile
.
Gets the checksum of a file
Description
Gets the checksum of a file.
Usage
## S3 method for class 'GenericDataFile'
getChecksum(this, write=NA, force=FALSE, verbose=FALSE, ...)
Arguments
write |
If |
force |
If |
verbose |
... |
... |
Not used. |
Value
Returns a character
string, which can be NA
if file is missing.
Author(s)
Henrik Bengtsson
See Also
Internally digest
is used.
*readChecksum()
.
*writeChecksum()
.
*compareChecksum()
.
For more information see GenericDataFile
.
Generates a deterministic checksum for an R object
Description
Generates a deterministic checksum for an R object that can be used to identify the data set.
Usage
## S3 method for class 'GenericDataFileSet'
getChecksum(this, ...)
Arguments
... |
Arguments passed to |
Value
Returns the checksum as a character
string.
Author(s)
Henrik Bengtsson
See Also
Internally, the checksum is calculated on the objects returned by
*getChecksumObjects()
.
For more information see GenericDataFileSet
.
Retrieves objects that uniquely identifying the data set
Description
Retrieves objects that uniquely identifying the data set.
Usage
## S3 method for class 'GenericDataFileSet'
getChecksumObjects(this, ..., verbose=FALSE)
Arguments
... |
Not used. |
verbose |
Details
By default, a GenericDataFileSet is assumed to be uniquely identifiable by its files and their fullnames (possibly translated).
Value
Returns a named list
of objects that can be used to uniquely
identifying the GenericDataFileSet.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Gets the column names
Description
Gets the column names.
Usage
## S3 method for class 'ColumnNamesInterface'
getColumnNames(this, ..., translate=TRUE)
Arguments
translate |
If |
... |
Not used. |
Value
Author(s)
Henrik Bengtsson
See Also
*getDefaultColumnNames()
.
For more information see ColumnNamesInterface
.
Gets when the file was created
Description
Gets when the file was created.
Usage
## S3 method for class 'GenericDataFile'
getCreatedOn(this, ...)
Arguments
... |
Not used. |
Value
Returns a POSIXct
time stamp.
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
Gets the default column names
Description
Gets the default column names, that is, the column names without translations.
Usage
## S3 method for class 'ColumnNamesInterface'
getDefaultColumnNames(...)
Arguments
... |
Not used. |
Value
Author(s)
Henrik Bengtsson
See Also
*getColumnNames()
.
For more information see ColumnNamesInterface
.
Gets the default column names
Description
Gets the default column names by inferring it from the file header.
Usage
## S3 method for class 'TabularTextFile'
getDefaultColumnNames(this, ...)
Arguments
... |
Optional arguments passed |
Value
Returns character
vector
,
or NULL
if there are no column names in the file header.
Author(s)
Henrik Bengtsson
See Also
For more information see TabularTextFile
.
Gets the default full name
Description
Gets the default full name, that is, the fullname without translations.
Usage
## S3 method for class 'FullNameInterface'
getDefaultFullName(...)
Arguments
... |
Not used. |
Details
The full name of a file is the filename excluding any
extension (and period).
For instance, the full name of path/to/foo,a.2,b.ext
is
foo,a.2,b
.
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
*getName()
.
*getTags()
.
For more information see FullNameInterface
.
Gets the full name of the file
Description
Gets the full name of the file, that is the filename without the filename extension.
Usage
## S3 method for class 'GenericDataFile'
getDefaultFullName(this, ...)
Arguments
... |
Not used. |
Details
The full name of a file is the filename excluding any
extension (and period).
For instance, the full name of path/to/foo,a.2,b.ext
is
foo,a.2,b
.
Value
Returns a character
string (NA
if "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Gets the default full name of the file set
Description
Gets the default full name of the file set, that is the name of the directory without parent directories.
Usage
## S3 method for class 'GenericDataFileSet'
getDefaultFullName(this, parent=getDepth(this, default = NULL), ...)
Arguments
parent |
The number of generations up in the directory tree the directory name should be retrieved. By default the current directory is used. |
... |
Not used. |
Details
By default, the full name of a file set is the name of the directory
containing all the files, e.g. the name of file set
path/foo,c/to,a,b/*
is to,a,b
.
Argument parent=1
specifies that the parent directory should be
used, e.g. foo,c
.
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Gets the filename extension
Description
Gets the filename extension.
Usage
## S3 method for class 'GenericDataFile'
getExtension(this, ...)
Arguments
... |
Arguments passed to |
Value
Returns a character
string (which is of length zero if "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Get a particular file of the file set
Description
Get a particular file of the file set.
Usage
## S3 method for class 'GenericDataFileSet'
getFile(this, idx, ...)
Arguments
idx |
A |
... |
Not used. |
Value
Returns a @GenericDataFile.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
If argument idx
is a character
, then internally
*indexOf()
is used to identify what to return.
Gets the size of a file
Description
Gets the size of a file.
Usage
## S3 method for class 'GenericDataFile'
getFileSize(this, what=c("numeric", "units"), sep="", ...)
Arguments
what |
A |
sep |
A |
... |
Not used. |
Value
Returns a numeric
or a character
string.
A missing value (NA
) is returned if the file does not exist.
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
Gets the file type of a file
Description
Gets the file type of a file.
Usage
## S3 method for class 'GenericDataFile'
getFileType(this, ...)
Arguments
... |
Not used. |
Details
By default, this methods returns the filename extension, but subclasses may override this.
Value
Returns a character
in lower case letters
(which is of length zero if "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Gets the filename of the file
Description
Gets the filename of the file.
Usage
## S3 method for class 'GenericDataFile'
getFilename(this, ...)
Arguments
... |
Optional arguments passed to |
Details
The filename of a file is the pathname excluding any path.
For instance, the filename of path/to/foo,a.2,b.ext
is
foo,a.2,b.ext
.
Value
Returns a character
string (NA
if an "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Gets the full name
Description
Gets the full name consisting of a name and tags.
Usage
## S3 method for class 'FullNameInterface'
getFullName(this, ..., translate=TRUE)
Arguments
translate |
If |
... |
Not used. |
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
*getName()
.
*getTags()
.
For more information see FullNameInterface
.
Gets the file header
Description
Gets the file header.
Usage
## S3 method for class 'TabularTextFile'
getHeader(this, ..., header=TRUE, force=FALSE)
Arguments
... |
Passed to internal |
header |
A |
force |
If |
Value
Returns a named list
.
Author(s)
Henrik Bengtsson
See Also
For more information see TabularTextFile
.
Gets when the file was last accessed
Description
Gets when the file was last accessed.
Usage
## S3 method for class 'GenericDataFile'
getLastAccessedOn(this, ...)
Arguments
... |
Not used. |
Value
Returns a POSIXct
time stamp.
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
Gets when the file was last modified
Description
Gets when the file was last modified.
Usage
## S3 method for class 'GenericDataFile'
getLastModifiedOn(this, ...)
Arguments
... |
Not used. |
Value
Returns a POSIXct
time stamp.
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
Gets the name
Description
Gets the name.
Usage
## S3 method for class 'FullNameInterface'
getName(this, ...)
Arguments
... |
Additional arguments passed to |
Details
The name is the part of the fullname that precedes any comma.
For instance, the name of foo,a.2,b
is foo
.
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
*getFullName()
.
*getTags()
.
For more information see FullNameInterface
.
Gets the names (or fullnames) of the files in the file set
Description
Gets the names (or fullnames) of the files in the file set.
Usage
## S3 method for class 'GenericDataFileSet'
getNames(this, ...)
## S3 method for class 'GenericDataFileSet'
getFullNames(this, ..., onRemapping=getOption("R.filesets::onRemapping", "ignore"))
Arguments
... |
Arguments passed to |
onRemapping |
Action to take if the fullnames before and after translation do not map consistently to the same file indices. |
Value
Returns a character
vector
of length equal to the number of files
in the set.
Author(s)
Henrik Bengtsson
See Also
*indexOf()
For more information see GenericDataFileSet
.
Gets the path (directory) of the file
Description
Gets the path (directory) of the file.
Usage
## S3 method for class 'GenericDataFile'
getPath(this, ...)
Arguments
... |
Optional arguments passed to |
Value
Returns a character
string (NA
if an "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Gets the path (directory) of the file set
Description
Gets the path (directory) of the file set.
Usage
## S3 method for class 'GenericDataFileSet'
getPath(this, ...)
Arguments
... |
Not used. |
Value
Returns a character
.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Gets the pathname of the file
Description
Gets the pathname of the file.
Usage
## S3 method for class 'GenericDataFile'
getPathname(this, absolute=FALSE, ...)
Arguments
absolute |
If |
... |
Not used. |
Value
Returns the pathname as character
string
(or NULL
if an "empty" file).
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Gets the pathnames of the files in the file set
Description
Gets the pathnames of the files in the file set.
Usage
## S3 method for class 'GenericDataFileSet'
getPathnames(this, ...)
Arguments
... |
Not used. |
Value
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Gets the tags
Description
Gets the tags.
Usage
## S3 method for class 'FullNameInterface'
getTags(this, pattern=NULL, collapse=NULL, ..., named=FALSE, na.rm=TRUE,
useCustomTags=TRUE)
Arguments
pattern |
An optional regular expression used to filter out tags.
If |
collapse |
A |
... |
Additional arguments passed to |
named |
If |
na.rm |
If |
useCustomTags |
If |
Details
The tags of a fullname are the comma separated parts of the
fullname that follows the the first comma, if any.
For instance, the tags of foo,a.2,b
are a.2
and b
.
Any custom tag that equals "*"
is replaced by the comma separated
tags from the fullname.
Value
Returns a character
vector
(possibly NA
) or NULL
.
Author(s)
Henrik Bengtsson
See Also
*getFullName()
.
*getName()
.
For more information see FullNameInterface
.
Compresses/uncompresses a file
Description
Compresses/uncompresses a file using gzip compression.
When compressing (uncompressing), the new filename has suffix .gz
appended (removed), which is also used to test if a file is gzip'ed
or not.
Usage
## S3 method for class 'GenericDataFile'
gzip(this, ...)
## S3 method for class 'GenericDataFile'
gunzip(this, ...)
## S3 method for class 'GenericDataFile'
isGzipped(this, ...)
Arguments
... |
Arguments passed to "R.utils::gzip" and "R.utils::gunzip", respectively. |
Value
Returns (invisibly) the updated pathname. When compressing (uncompressing), an exception is thrown if the file is already compressed (not compressed). An exception is thrown if the file does not exist.
Author(s)
Henrik Bengtsson
See Also
Internally gzip
is used.
For more information see GenericDataFile
.
Compresses/uncompresses a set of files
Description
Compresses/uncompresses a set of files using gzip compression.
When compressing (uncompressing), each of the GenericDataFile
of the file set are compressed (uncompressed).
Usage
## S3 method for class 'GenericDataFileSet'
gzip(this, ...)
## S3 method for class 'GenericDataFileSet'
gunzip(this, ...)
Arguments
... |
Arguments passed to |
Value
Returns (invisibly) itself.
Author(s)
Henrik Bengtsson
See Also
Internally gzip
and gunzip
are used.
For more information see GenericDataFileSet
.
Checks whether the file has been modified
Description
Checks whether the file has been modified since last time checked.
Usage
## S3 method for class 'GenericDataFile'
hasBeenModified(this, update=TRUE, unknown=TRUE, ...)
Arguments
unknown |
The |
update |
If |
... |
Not used. |
Value
Returns TRUE
, FALSE
, or the value of argument unknown
.
Author(s)
Henrik Bengtsson
See Also
file.info
().
For more information see GenericDataFile
.
Checks if there are column names in the header
Description
Checks if there are column names in the header.
Usage
## S3 method for class 'TabularTextFile'
hasColumnHeader(this, ...)
Arguments
... |
Not used. |
Value
Returns a logical
.
Author(s)
Henrik Bengtsson
See Also
For more information see TabularTextFile
.
Checks whether the fullname contains a given set of tag(s)
Description
Checks whether the fullname contains a given set of tag(s).
Usage
## S3 method for class 'FullNameInterface'
hasTags(this, tags, ...)
## S3 method for class 'FullNameInterface'
hasTag(this, tag, ...)
Arguments
tags , tag |
|
... |
Additional arguments passed to |
Value
Returns TRUE
if all tags are part of the fullname, otherwise
FALSE
.
Author(s)
Henrik Bengtsson
See Also
*getTags()
.
*getName()
.
For more information see FullNameInterface
.
Finds indices of a subset of files
Description
Finds indices of a subset of files whose names match a given set of names or name patterns.
Usage
## S3 method for class 'GenericDataFileSet'
indexOf(this, patterns=NULL, by=c("exact", "regexp", "fixed"), ...,
onMissing=c("NA", "error"))
Arguments
patterns |
A |
by |
A |
... |
Not used. |
Details
If an element of patterns
contains a comma, then that element
is matched against the *getFullNames()
, otherwise it is
matched against *getNames()
.
First each pattern is matched by regular expression rules, and if
there is not match, then by fixed strings.
Value
Returns an integer
vector
of length K with elements in
[1,*length()
] or (integer) NA
(for non-matched names).
Author(s)
Henrik Bengtsson
See Also
*getNames()
For more information see GenericDataFileSet
.
Checks if this is an existing file
Description
Checks if this is an existing file and not a directory.
Usage
## S3 method for class 'GenericDataFile'
isFile(this, ...)
Arguments
... |
Not used. |
Value
Returns a TRUE
if an existing file (and not a directory),
otherwise FALSE
.
Author(s)
Henrik Bengtsson
See Also
isFile
.
For more information see GenericDataFile
.
Gets the number of files in the set
Description
Gets the number of files in the set.
Usage
## S3 method for class 'GenericDataFileSet'
length(x)
## S3 method for class 'GenericDataFileSet'
nbrOfFiles(this, ...)
Value
Returns an non-negative integer
.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Creates a symbolic file link
Description
Creates a symbolic file link to a GenericDataFile
at/from a given
destination pathname.
Usage
## S3 method for class 'GenericDataFile'
linkTo(this, filename=getFilename(this), path=NULL, skip=!overwrite, overwrite=FALSE,
...)
Arguments
filename , path |
The filename and the path for the link. The default is to use the same filename as the source file. |
skip |
If |
overwrite |
If |
... |
Additional arguments passed to |
Value
Returns a GenericDataFile
(of the same class as the source file)
referring to the file via the link.
Required privileges on Windows
In order for this method to succeed on Windows,
the client/R session must run with sufficient privileges.
See createLink
for more details.
Author(s)
Henrik Bengtsson
See Also
To copy a GenericDataFile
, see *copyTo()
.
Internally createLink
is used.
For more information see GenericDataFile
.
Reads data from a RDS file
Description
Reads data from a RDS file.
Usage
## Default S3 method:
loadRDS(file, ...)
## S3 method for class 'RdsFile'
loadRDS(file, ...)
Arguments
file |
A |
... |
Additional arguments passed to |
Value
Returns an R object.
Author(s)
Henrik Bengtsson
See Also
readRDS
().
Reads data from a RDS file
Description
Reads data from a RDS file.
Usage
## S3 method for class 'RDataFile'
loadToEnv(file, ...)
Arguments
file |
A |
... |
Additional arguments passed to |
Value
Returns an environment
.
Author(s)
Henrik Bengtsson
See Also
Gets the number of columns
Description
Gets the number of columns.
Usage
## S3 method for class 'ColumnNamesInterface'
nbrOfColumns(this, ...)
Arguments
... |
Not used. |
Value
Returns an integer
.
If the number of columns cannot be inferred, NA
is returned.
Author(s)
Henrik Bengtsson
See Also
*getColumnNames()
.
For more information see ColumnNamesInterface
.
Counts the number of lines in the data file
Description
Counts the number of lines in the data file. The count include header rows, comments and more.
Usage
## S3 method for class 'TabularTextFile'
nbrOfLines(this, fast=FALSE, ...)
Arguments
fast |
If |
... |
Optional arguments passed to |
Value
Author(s)
Henrik Bengtsson
See Also
To count the number of data rows is the data table,
use *nbrOfRows()
.
Internally, countLines
is used.
For more information see TabularTextFile
.
Gets the number of data rows
Description
Gets the number of data rows.
Usage
## S3 method for class 'GenericTabularFile'
nbrOfRows(...)
Arguments
... |
Not used. |
Value
Returns an integer
.
Author(s)
Henrik Bengtsson
See Also
*dim()
.
For more information see GenericTabularFile
.
Counts the number of data rows
Description
Counts the number of data rows. The count does not include the header rows or comments.
Usage
## S3 method for class 'TabularTextFile'
nbrOfRows(this, fast=FALSE, ...)
Arguments
fast |
Argument passed to |
... |
Optional arguments passed to |
Value
Author(s)
Henrik Bengtsson
See Also
The number of data rows is always less or equal to the number of lines
as returned by *nbrOfLines()
.
Internally, countLines
is used.
For more information see TabularTextFile
.
Reads the checksum value
Description
Reads the checksum value.
Usage
## S3 method for class 'ChecksumFile'
readChecksum(this, ...)
Arguments
... |
Not used. |
Details
The content of the checksum file is trimmed from comment lines, whitespaces and then validated that the remaining part contains a hexadecimal value.
Value
Returns a lower-case character
string.
Author(s)
Henrik Bengtsson
See Also
For more information see ChecksumFile
.
Reads the value of the corresponding checksum file
Description
Reads the value of the corresponding checksum file, if existing.
Usage
## S3 method for class 'GenericDataFile'
readChecksum(this, ...)
Arguments
... |
Not used. |
Details
The content of the checksum file is trimmed from comment lines, whitespaces and then validated that the remaining part contains a hexadecimal value.
Value
Returns a character
string, which can be NA
if file is missing.
An exception is thrown if the file does not exist, and hence not
the checksum file.
Author(s)
Henrik Bengtsson
See Also
*validateChecksum()
.
*compareChecksum()
.
*writeChecksum()
.
*getChecksum()
.
For more information see GenericDataFile
.
Reads a subset of the columns as a data frame
Description
Reads a subset of the columns as a data frame.
Usage
## S3 method for class 'GenericTabularFile'
readColumns(...)
Arguments
... |
Not used. |
Value
Returns a data.frame
.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericTabularFile
.
Reads data from a tabular file
Description
Reads data from a tabular file or a set of such files.
Usage
## Default S3 method:
readDataFrame(filename, path=NULL, ...)
Arguments
filename , path |
|
... |
Additional arguments passed to either
(i) |
Details
When reading multiple files at once, first each file is read into
a data.frame
, and then these data.frame
s are (by default) merged into
one data.frame
using rbind
(). This requires that the
same set of columns are read for each file. Which columns to read
can be controlled by specifying their names in
argument colClasses
. To change how the data.frame
s are
merged, use argument combineBy
.
For more information, follow the help on the above to
readDataFrame()
help links.
Value
Returns a data.frame
.
Author(s)
Henrik Bengtsson
See Also
read.table
.
For further details, see classes TabularTextFile
and
TabularTextFileSet
.
Examples
path <- system.file("exData/dataSetA,original", package="R.filesets")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Example: Standard tab-delimited file with header comments
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pathname <- file.path(path, "fileA,20100112.dat")
# Read all data
df <- readDataFrame(pathname)
print(df)
# Read columns 'x', 'y', and 'char'
df <- readDataFrame(pathname, colClasses=c("(x|y)"="integer", "char"="character"))
print(df)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Example: Tab-delimited file with header comments but
# also two garbage at the very beginning
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pathname <- file.path(path, "fileA,20130116.datx")
# Explicitly skip the two rows
df <- readDataFrame(pathname, skip=2)
print(df)
# Skip until the first data row
df <- readDataFrame(pathname, skip="^x")
print(df)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Example: Tab-delimited file without column header
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
path <- system.file("exData/dataSetB", package="R.filesets")
pathname <- file.path(path, "fileF,noHeader.dat")
# Incorrectly assuming column header
df <- readDataFrame(pathname)
print(df)
# No column header
df <- readDataFrame(pathname, header=FALSE)
print(df)
Reads the tabular data as a data frame
Description
Reads the tabular data as a data frame.
Usage
## S3 method for class 'GenericTabularFile'
readDataFrame(...)
Arguments
... |
Not used. |
Value
Returns a data.frame
.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericTabularFile
.
Reads the tabular data as a data frame
Description
Reads the tabular data as a data frame.
Usage
## S3 method for class 'TabularTextFile'
readDataFrame(this, con=NULL, rows=NULL, nrow=NULL, trimQuotes=FALSE, ..., debug=FALSE,
verbose=FALSE)
Arguments
con |
(Internal) If a |
rows |
(Optional) An |
nrow |
(Optional) An |
trimQuotes |
(Optional) If |
... |
Passed to internal |
debug |
If |
verbose |
Value
Returns a data.frame
.
Reading quoted numerics
If a specific data column is specified as being numeric in
argument colClasses
and that column contains quoted values
it is necessary to use argument trimQuotes=TRUE
, otherwise
scan
() throws an exception similar to:
scan() expected 'a real', got '"1.0"'
.
Author(s)
Henrik Bengtsson
See Also
For more information see TabularTextFile
.
Reads the tabular data from all files as data frames
Description
Reads the tabular data from all files as data frames and combines them into one data frame (by default).
Usage
## S3 method for class 'TabularTextFileSet'
readDataFrame(this, ..., combineBy=function(x) Reduce(rbind, x), verbose=FALSE)
Arguments
... |
Arguments passed to
|
combineBy |
A |
Value
Returns what combineBy
returns, which defaults to a data.frame
.
If combineBy=NULL
, then a named list
of data.frame
:s is returned.
Author(s)
Henrik Bengtsson
See Also
For more information see TabularTextFileSet
.
Examples
# Setup a file set consisting of all *.dat tab-delimited files
# in a particular directory
path <- system.file("exData/dataSetA,original", package="R.filesets")
ds <- TabularTextFileSet$byPath(path, pattern="[.]dat$")
print(ds)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Read data frames from each of the files
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dataList <- lapply(ds, readDataFrame)
print(dataList)
rows <- c(3:5, 8, 2)
dataList <- lapply(ds, readDataFrame, rows=rows)
print(dataList)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Read common columns and stack into one data frame
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
colNames <- Reduce(intersect, lapply(ds, getColumnNames))
cat("Common column names:\n")
print(colNames)
# Read the *common* columns "as is" (hence 'NA')
colClasses <- rep(NA, times=length(colNames))
names(colClasses) <- colNames
cat("Column class patterns:\n")
print(colClasses)
data <- readDataFrame(ds, colClasses=colClasses)
print(data)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Translate column names on the fly
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
lapply(ds, FUN=setColumnNamesTranslator, function(names, ...) toupper(names))
data <- readDataFrame(ds, colClasses=c("(X|Y)"="integer", "CHAR"="character"))
print(data)
Reads the lines of the data file as strings
Description
Reads the lines of the data file as strings.
Usage
## S3 method for class 'TabularTextFile'
readLines(con, ...)
Arguments
... |
Optional arguments passed to |
Value
Author(s)
Henrik Bengtsson
See Also
*readDataFrame()
.
For more information see TabularTextFile
.
Renames/moves a file
Description
Renames/moves a file.
Usage
## S3 method for class 'GenericDataFile'
renameTo(this, filename=getFilename(this), path=NULL, ..., verbose=FALSE)
Arguments
filename , path |
The filename and the path for the destination file. The default is to use the same filename as the source file. The destination pathname must not be the same as the source file, otherwise an exception is thrown. |
... |
Additional arguments passed to |
verbose |
... |
Value
Returns the source GenericDataFile
.
Author(s)
Henrik Bengtsson
See Also
Internally renameFile
.
*copyTo()
.
For more information see GenericDataFile
.
Sets the column names
Description
Sets the column names. This is done using a names translator function that returns the specified names.
Usage
## S3 method for class 'ColumnNamesInterface'
setColumnNames(this, ...)
Arguments
... |
Arguments, typically a |
Value
Returns (invisibly) itself.
Author(s)
Henrik Bengtsson
See Also
*getColumnNames()
.
For more information see ColumnNamesInterface
.
Sets the full name
Description
Sets the full name. This is done using a fullname translator function that returns the specified fullname.
Usage
## S3 method for class 'FullNameInterface'
setFullName(this, ...)
Arguments
... |
Arguments, typically a |
Value
Returns (invisibly) itself.
Author(s)
Henrik Bengtsson
See Also
*getFullName()
.
*setName()
.
For more information see FullNameInterface
.
Sets the name part of the fullname
Description
Sets the name part of the fullname, leaving the tags untouched.
Usage
## S3 method for class 'FullNameInterface'
setName(this, name=NULL, ...)
Arguments
name |
The new name part of the fullname.
If |
... |
Not used. |
Value
Returns (invisibly) itself.
Author(s)
Henrik Bengtsson
See Also
*setFullName()
.
*getName()
.
For more information see FullNameInterface
.
Sets the tags
Description
Sets the tags.
Usage
## S3 method for class 'FullNameInterface'
setTags(this, tags="*", ...)
Arguments
tags |
|
... |
Not used. |
Details
See *getTags()
for so called special tags.
Value
Returns (invisibly) itself.
Author(s)
Henrik Bengtsson
See Also
*getTags()
.
For more information see FullNameInterface
.
Sorts the set
Description
Sorts the set by one of several ordering schema.
Usage
## S3 method for class 'GenericDataFileSet'
sortBy(this, by=c("lexicographic", "mixedsort", "mixeddecimal", "mixedroman",
"filesize"), decreasing=FALSE, caseSensitive=FALSE, ...)
Arguments
by |
A |
decreasing |
If |
caseSensitive |
If |
... |
Not used. |
Details
The set is ordering by the fullnames.
If by="lexicographic"
, lexicographic ordering is used,
sometimes also referred to as alphabetic ordering.
If by="mixeddecimal"
, mixedsort ordering acknowledging
decimal numbers is used, cf. mixedsort
.
If by="mixedroman"
, mixedsort ordering acknowledging
roman numerals is used, cf. mixedsort
.
Value
Returns returns itself with the set ordered accordingly.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Asserts that the checksum matches the checksum of file
Description
Asserts that the checksum matches the checksum of file.
Usage
## S3 method for class 'ChecksumFile'
validate(this, ..., verbose=FALSE)
Arguments
... |
Not used. |
verbose |
... |
Value
Returns TRUE
.
If checksum on record does not match the file, an exception is thrown.
Author(s)
Henrik Bengtsson
See Also
For more information see ChecksumFile
.
Validates the content of a file
Description
Validates the content of a file.
Usage
## S3 method for class 'GenericDataFile'
validate(this, ...)
Arguments
... |
Not used. |
Value
If the file is invalid, then an error is thrown.
If the files is valid, then TRUE
is returned.
Otherwise, NA
is returned, which happens if the file was not validated.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFile
.
Validates all files in the data set
Description
Validates all files in the data set.
Usage
## S3 method for class 'GenericDataFileSet'
validate(this, ...)
Arguments
... |
Not used. |
Value
If one of the files is invalid, then an error is thrown.
If all of the files are valid, then TRUE
is returned.
Otherwise, NA
is returned.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericDataFileSet
.
Asserts that the file checksum matches the one of the checksum file
Description
Asserts that the file checksum matches the one of the checksum file.
Usage
## S3 method for class 'GenericDataFile'
validateChecksum(this, ...)
Arguments
... |
Not used. |
Value
An exception is thrown if not, that is, if *compareChecksum()
returns FALSE
.
Author(s)
Henrik Bengtsson
See Also
*validateChecksum()
.
*readChecksum()
.
*writeChecksum()
.
*getChecksum()
.
For more information see GenericDataFile
.
Write the file checksum to a checksum file
Description
Write the file checksum to a checksum file having the same filename with suffix .md5
added.
Usage
## S3 method for class 'GenericDataFile'
writeChecksum(this, ..., skip=FALSE)
Arguments
skip |
If |
... |
Not used. |
Value
Returns (invisibly) the pathname to the checksum file. An exception is thrown if the file does not exist.
Author(s)
Henrik Bengtsson
See Also
*validateChecksum()
.
*compareChecksum()
.
*readChecksum()
.
*getChecksum()
.
For more information see GenericDataFile
.
Read each column from a data file and exports it to a separate file
Description
Read each column from a data file and exports it to a separate file. Since each column is processed independently of the others, this method is memory efficient and can handle very large data files.
Usage
## S3 method for class 'GenericTabularFile'
writeColumnsToFiles(this, destPath, filenameFmt="%s.txt", tags=NULL, columnName=NULL,
header=NULL, ..., verbose=FALSE)
Arguments
destPath |
The output directory where to write the files. |
filenameFmt |
An |
tags |
An optional |
columnName |
... |
header |
An optional file header. |
... |
Not used. |
verbose |
See |
Details
Each file generated is written atomically by first writing to a temporary file which is then renamed if successfully written. This minimizes the risk for creating incomplete files, which otherwise may occur if for instance an interrupt occurred.
Value
Returns (invisibly) a character
vector
of all output files.
Author(s)
Henrik Bengtsson
See Also
For more information see GenericTabularFile
.