Learn R Programming

fritools (version 3.3.0)

paths: Set or Get the path Attribute to or from an Object

Description

We set paths on some objects, these are convenience wrappers to attr.

Usage

get_path(x, force = FALSE)

set_path(x, path, action = c(NA, "read", "write"), overwrite = FALSE)

Arguments

x

An object.

force

Force the retrieval, even if the path is not valid? Only meant for unit testing, leave alone!

path

The path to be set.

action

Do we have a read or write process? Passed by read_csv and write_csv. Leave alone otherwise.

overwrite

Overwrite an existing path attribute instead of throwing an error?

Value

For get_path the value of attr(x, "path").

For set_path the modified object.

See Also

Other file utilities: file_copy(), file_modified_last(), file_save(), find_files(), get_mtime(), get_unique_string(), is_files_current(), is_path(), search_files(), split_code_file(), touch()

Examples

Run this code
# NOT RUN {
x <- 2
path <- tempfile()
touch(path)
x <- set_path(x, path)
get_path(x)
# }

Run the code above in your browser using DataLab