These functions are for working with source files and more generally with “source references” ("srcref"), i.e., references to source code. The resulting data is used for printing and source level debugging, and is typically available in interactive R sessions, namely when options(keep.source = TRUE).
srcfile(filename, encoding = getOption("encoding"), Enc = "unknown")
srcfilecopy(filename, lines, timestamp = Sys.time(), isFile = FALSE)
srcfilealias(filename, srcfile)
getSrcLines(srcfile, first, last)
srcref(srcfile, lloc)
# S3 method for srcfile
print(x, …)
# S3 method for srcfile
summary(object, …)
# S3 method for srcfile
open(con, line, …)
# S3 method for srcfile
close(con, …)
# S3 method for srcref
print(x, useSource = TRUE, …)
# S3 method for srcref
summary(object, useSource = FALSE, …)
# S3 method for srcref
as.character(x, useSource = TRUE, to = x, …)
.isOpen(srcfile)
| Parameter | Description |
|---|---|
filename |
The name of a file. |
encoding |
The character encoding to assume for the file. |
Enc |
The encoding with which to make strings: see the encoding argument of parse. |
lines |
A character vector of source lines. Other R objects will be coerced to character. |
timestamp |
The timestamp to use on a copy of a file. |
isFile |
Is this srcfilecopy known to come from a file system file? |
srcfile |
A srcfile object. |
first, last, line |
Line numbers. |
lloc |
A vector of four, six or eight values giving a source location; see ‘Details’. |
x, object, con |
An object of the appropriate class. |
useSource |
Whether to read the srcfile to obtain the text of a srcref. |
to |
An optional second srcref object to mark the end of the character range. |
… |
Additional arguments to the methods; these will be ignored. |
# NOT RUN {
# has timestamp
src <- srcfile(system.file("DESCRIPTION", package = "base"))
summary(src)
getSrcLines(src, 1, 4)
ref <- srcref(src, c(1, 1, 2, 1000))
ref
print(ref, useSource = FALSE)
# }