is_git2rdata {git2rdata}R Documentation

Check Whether a Git2rdata Object is Valid.

Description

A valid git2rdata object has valid metadata.

Usage

is_git2rdata(file, root = ".", message = c("none", "warning", "error"))

Arguments

file

the name of the git2rdata object. Git2rdata objects cannot have dots in their name. The name may include a relative path. file is a path relative to the root. Note that file must point to a location within root.

root

The root of a project. Can be a file path or a git-repository. Defaults to the current working directory (".").

message

a single value indicating the type of messages on top of the logical value. "none": no messages, "warning": issue a warning in case of an invalid metadata file. "error": an invalid metadata file results in an error. Defaults to "none".

Value

A logical value. TRUE in case of a valid git2rdata object. Otherwise FALSE.

See Also

Other internal: is_git2rmeta(), meta(), upgrade_data()

Examples

# create a directory
root <- tempfile("git2rdata-")
dir.create(root)

# store a file
write_vc(iris[1:6, ], "iris", root, sorting = "Sepal.Length")
# check the stored file
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

# Remove the metadata from the existing git2rdata object. Then it stops
# being a git2rdata object.
junk <- file.remove(file.path(root, "iris.yml"))
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

# recreate the file and remove the data and keep the metadata. It stops being
# a git2rdata object, but the metadata remains valid.
write_vc(iris[1:6, ], "iris", root, sorting = "Sepal.Length")
junk <- file.remove(file.path(root, "iris.tsv"))
is_git2rmeta("iris", root)
is_git2rdata("iris", root)

[Package git2rdata version 0.4.0 Index]