ID EN
Miscellaneous

srcfile

R Base 3.6.2 🇮🇩 Bahasa Indonesia

Fungsi-fungsi ini untuk bekerja dengan file sumber dan lebih umum lagi dengan "referensi sumber" ("srcref"), yaitu referensi ke kode sumber. Data yang dihasilkan digunakan untuk pencetakan dan debugging tingkat sumber, dan biasanya tersedia dalam sesi R interaktif, yaitu ketika options(keep.source = TRUE).

Syntax

R
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)

Arguments

Parameter Deskripsi
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.

Return Value

srcfile mengembalikan objek srcfile.srcfilecopy mengembalikan objek srcfilecopy.getSrcLines mengembalikan vektor karakter baris kode sumber.srcref mengembalikan objek srcref.

Details

Fungsi dan kelas ini menangani referensi kode sumber. Fungsi srcfile menghasilkan objek kelas srcfile, yang berisi nama dan direktori file kode sumber, beserta stempel waktunya, untuk digunakan dalam debugging tingkat sumber (belum diimplementasikan) dan gema sumber. Pengkodean file disimpan; lihat file untuk diskusi tentang pengkodean, dan iconvlist untuk daftar pengkodean yang diperbolehkan pada platform Anda. Fungsi srcfilecopy menghasilkan objek dari kelas turunan srcfilecopy, yang menyimpan baris sumber dalam vektor karakter. Ini menyalin nilai argumen isFile, untuk membantu debugger mengidentifikasi apakah teks ini berasal dari file nyata dalam sistem file. Fungsi srcfilealias menghasilkan objek dari kelas turunan srcfilealias, yang diberi nama alternatif t

Contoh

Example
R
# 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)
# }

See Also

getSrcFilename for extracting information from a source reference or removeSource to remove it from a (non-primitive) function (aka ‘closure’).