Description Usage Arguments Value See Also Examples
Get or set the path of an object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | path(object, ...)
path(object, ...) <- value
basename(path, ...)
basename(path, ...) <- value
dirname(path, ...)
dirname(path, ...) <- value
## The purpose of the following methods is to make the basename() and
## dirname() getters work out-of-the-box on any object for which the
## path() getter works.
## S4 method for signature 'ANY'
basename(path, ...)
## S4 method for signature 'ANY'
dirname(path, ...)
## The purpose of the following replacement methods is to make the
## basename() and dirname() setters work out-of-the-box on any object
## for which the path() getter and setter work.
## S4 replacement method for signature 'character'
basename(path, ...) <- value
## S4 replacement method for signature 'ANY'
basename(path, ...) <- value
## S4 replacement method for signature 'character'
dirname(path, ...) <- value
## S4 replacement method for signature 'ANY'
dirname(path, ...) <- value
|
object |
An object containing paths. Even though it will typically contain
a single path, |
... |
Additional arguments, for use in specific methods. |
value |
For For |
path |
A character vector or an object containing paths. |
A character vector for path(object)
, basename(path)
,
and dirname(path)
. Typically of length 1 but not necessarily.
Possibly with names on it for path(object)
.
base::basename
for the functions the
basename
and dirname
generics are based on.
showMethods
for displaying a summary of the
methods defined for a given generic function.
selectMethod
for getting the definition of
a specific method.
path,RsamtoolsFile-method in the
Rsamtools package for an example of a specific
path
method (defined for RsamtoolsFile
objects).
BiocGenerics for a summary of all the generics defined in the BiocGenerics package.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | ## ---------------------------------------------------------------------
## GENERIC FUNCTIONS AND DEFAULT METHODS
## ---------------------------------------------------------------------
path
showMethods("path")
`path<-`
showMethods("path<-")
basename
showMethods("basename")
`basename<-`
showMethods("basename<-")
dirname
showMethods("dirname")
`dirname`
showMethods("dirname<-")
## Default basename() and dirname() getters:
selectMethod("basename", "ANY")
selectMethod("dirname", "ANY")
## Default basename() and dirname() setters:
selectMethod("basename<-", "character")
selectMethod("basename<-", "ANY")
selectMethod("dirname<-", "character")
selectMethod("dirname<-", "ANY")
## ---------------------------------------------------------------------
## OBJECTS CONTAINING PATHS
## ---------------------------------------------------------------------
## Let's define a simple class to represent objects that contain paths:
setClass("A", slots=c(stuff="ANY", path="character"))
a <- new("A", stuff=runif(5),
path=c(one="path/to/file1", two="path/to/file2"))
## path() getter:
setMethod("path", "A", function(object) object@path)
path(a)
## Because the path() getter works on 'a', now the basename() and
## dirname() getters also work:
basename(a)
dirname(a)
## path() setter:
setReplaceMethod("path", "A",
function(object, ..., value)
{
if (length(list(...)) != 0L) {
dots <- match.call(expand.dots=FALSE)[[3L]]
stop(BiocGenerics:::unused_arguments_msg(dots))
}
object@path <- value
object
}
)
a <- new("A", stuff=runif(5))
path(a) <- c(one="path/to/file1", two="path/to/file2")
path(a)
## Because the path() getter and setter work on 'a', now the basename()
## and dirname() setters also work:
basename(a) <- toupper(basename(a))
path(a)
dirname(a) <- "~/MyDataFiles"
path(a)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.