ID EN
Miscellaneous

library

R Base 3.6.2 🇮🇩 Bahasa Indonesia

perpustakaan dan memerlukan memuat dan melampirkan paket tambahan.

Syntax

R
library(package, help, pos = 2, lib.loc = NULL,
        character.only = FALSE, logical.return = FALSE,
        warn.conflicts, quietly = FALSE,
        verbose = getOption("verbose"),
        mask.ok, exclude, include.only,
        attach.required = missing(include.only))<p></p><p>require(package, lib.loc = NULL, quietly = FALSE,
        warn.conflicts,
        character.only = FALSE,
        mask.ok, exclude, include.only,
        attach.required = missing(include.only))</p><p>conflictRules(pkg, mask.ok = NULL, exclude = NULL)</p>

Arguments

Parameter Deskripsi
package, help the name of a package, given as a name or literal character string, or a character string, depending on whether character.only is FALSE (default) or TRUE.
pos the position on the search list at which to attach the loaded namespace. Can also be the name of a position on the current search list as given by search().
lib.loc a character vector describing the location of R library trees to search through, or NULL. The default value of NULL corresponds to all libraries currently known to .libPaths(). Non-existent library trees are silently ignored.
character.only a logical indicating whether package or help can be assumed to be character strings.
logical.return logical. If it is TRUE, FALSE or TRUE is returned to indicate success.
warn.conflicts logical. If TRUE, warnings are printed about conflicts from attaching the new package. A conflict is a function masking a function, or a non-function masking a non-function. The default is TRUE unless specified as FALSE in the conflicts.policy option.
verbose a logical. If TRUE, additional diagnostics are printed.
quietly a logical. If TRUE, no message confirming package attaching is printed, and most often, no errors/warnings are printed if package attaching fails.
pkg character string naming a package.
mask.ok character vector of names of objects that can mask objects on the search path without signaling an error when strict conflict checking is enabled
exclude,include.only character vector of names of objects to exclude or include in the attached frame. Only one of these arguments may be used in a call to library or require.
attach.required logical specifying whether required packages listed in the Depends clause of the DESCRIPTION file should be attached automatically.

Return Value

Biasanya perpustakaan mengembalikan (tidak terlihat) daftar paket yang dilampirkan, tetapi TRUE atau FALSE jika logika.return adalah TRUE. Ketika dipanggil sebagai perpustakaan() ia mengembalikan objek kelas "libraryIQR", dan untuk perpustakaan(help=), salah satu kelas "packageInfo". memerlukan pengembalian (tidak terlihat) logika yang menunjukkan apakah paket yang diperlukan tersedia.

Details

perpustakaan(paket) dan memerlukan(paket) keduanya memuat namespace paket dengan nama paket dan melampirkannya pada daftar pencarian. require dirancang untuk digunakan di dalam fungsi lain; ia mengembalikan FALSE dan memberikan peringatan (daripada kesalahan seperti yang dilakukan perpustakaan() secara default) jika paket tidak ada. Kedua fungsi tersebut memeriksa dan memperbarui daftar paket yang terpasang saat ini dan tidak memuat ulang namespace yang sudah dimuat. (Jika Anda ingin memuat ulang paket seperti itu, panggil detach(unload = TRUE) atau unloadNamespace terlebih dahulu.) Jika Anda ingin memuat paket tanpa melampirkannya pada daftar pencarian, lihat requireNamespace. Untuk menyembunyikan pesan selama pemuatan paket, gunakan supressPackageStartupMessages: ini akan menyembunyikan semua pesan dari R itu sendiri tetapi tidak harus semua pesan dari pembuat paket.

Contoh

Example
R
# NOT RUN {
library()                   # list all available packages
library(lib.loc = .Library) # list all packages in the default library
# }
# NOT RUN {
library(help = splines)     # documentation on package 'splines'
# }
# NOT RUN {
library(splines)            # attach package 'splines'
require(splines)            # the same
search()                    # "splines", too
detach("package:splines")

# if the package name is in a character vector, use
pkg <- "splines"
library(pkg, character.only = TRUE)
detach(pos = match(paste("package", pkg, sep = ":"), search()))

require(pkg, character.only = TRUE)
detach(pos = match(paste("package", pkg, sep = ":"), search()))

require(nonexistent)        # FALSE
# }
# NOT RUN {
## if you want to mask as little as possible, use
library(mypkg, pos = "package:base")
# }

See Also

.libPaths .packages. attach detach search objects autoload requireNamespace library.dynam data install.packages and installed.packages; INSTALL REMOVE. The initial set of packages attached is set by options(defaultPackages=): see also Startup.