import_data: Directly Return a Data-set From a Package

View source: R/import_data.R

import_dataR Documentation

Directly Return a Data-set From a Package

Description

The import_data() function gets a specified data set from a package.
Unlike utils::data(), the import_data() function returns the data set directly, and allows assigning the data set like so:
mydata <- import_data(...).

Usage

import_data(package, dataname, lib.loc = .libPaths())

Arguments

package

a single string, giving the name of the R-package.

dataname

a single string, giving the name of the data set.

lib.loc

character vector specifying library search path (the location of R library trees to search through).
The lib.loc argument would usually be .libPaths().
See also loadNamespace.

Value

Returns the data directly. Thus, one can assign the data like so: mydata <- import_data(...).

See Also

tinycodet_import

Examples


d <- import_data("datasets", "cars")
head(d)




tinycodet documentation built on Sept. 12, 2024, 7:03 a.m.