Skip to contents

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")
#> 09d5bfd6a65e682a4ca030c766348180861568c8 
#>                               "iris.tsv" 
#> 0d434e56d22a710c99c5b912e8624d52abd41aaf 
#>                               "iris.yml" 
# check the stored file
is_git2rmeta("iris", root)
#> [1] TRUE
is_git2rdata("iris", root)
#> [1] TRUE

# 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)
#> [1] FALSE
is_git2rdata("iris", root)
#> [1] FALSE

# 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")
#> 09d5bfd6a65e682a4ca030c766348180861568c8 
#>                               "iris.tsv" 
#> 0d434e56d22a710c99c5b912e8624d52abd41aaf 
#>                               "iris.yml" 
junk <- file.remove(file.path(root, "iris.tsv"))
is_git2rmeta("iris", root)
#> [1] TRUE
is_git2rdata("iris", root)
#> [1] FALSE