The function returns the names of all valid git2rdata objects. This implies
.tsv
files with a matching valid metadata file (.yml
). Invalid
metadata files result in a warning. The function ignores valid metadata
files without matching raw data (.tsv
).
See also
Other storage:
display_metadata()
,
prune_meta()
,
read_vc()
,
relabel()
,
rename_variable()
,
rm_data()
,
update_metadata()
,
verify_vc()
,
write_vc()
Examples
## on file system
# create a directory
root <- tempfile("git2rdata-")
dir.create(root)
# store a dataframe as git2rdata object. Capture the result to minimise
# screen output
junk <- write_vc(iris[1:6, ], "iris", root, sorting = "Sepal.Length")
# write a standard tab separate file (non git2rdata object)
write.table(iris, file = file.path(root, "standard.tsv"), sep = "\t")
# write a YAML file
yml <- list(
authors = list(
"Research Institute for Nature and Forest" = list(
href = "https://www.inbo.be/en")))
yaml::write_yaml(yml, file = file.path(root, "_pkgdown.yml"))
# list the git2rdata objects
list_data(root)
#> [1] "iris.tsv"
# list the files
list.files(root, recursive = TRUE)
#> [1] "_pkgdown.yml" "iris.tsv" "iris.yml" "standard.tsv"
# remove all .tsv files from valid git2rdata objects
rm_data(root, path = ".")
# check the removal of the .tsv file
list.files(root, recursive = TRUE)
#> [1] "_pkgdown.yml" "iris.yml" "standard.tsv"
list_data(root)
#> character(0)
# remove dangling git2rdata metadata files
prune_meta(root, path = ".")
#> Warning: Invalid metadata files found. See ?is_git2rmeta():
#> _pkgdown.yml
# check the removal of the metadata
list.files(root, recursive = TRUE)
#> [1] "_pkgdown.yml" "standard.tsv"
list_data(root)
#> character(0)
## on git repo
# initialise a git repo using git2r
repo_path <- tempfile("git2rdata-repo-")
dir.create(repo_path)
repo <- git2r::init(repo_path)
git2r::config(repo, user.name = "Alice", user.email = "alice@example.org")
# store a dataframe
write_vc(iris[1:6, ], "iris", repo, sorting = "Sepal.Length", stage = TRUE)
#> 09d5bfd6a65e682a4ca030c766348180861568c8
#> "iris.tsv"
#> 0d434e56d22a710c99c5b912e8624d52abd41aaf
#> "iris.yml"
# check that the dataframe is stored
status(repo)
#> Staged changes:
#> New: iris.tsv
#> New: iris.yml
#>
list_data(repo)
#> [1] "iris.tsv"
# commit the current version and check the git repo
commit(repo, "add iris data", session = TRUE)
#> [c7da41e] 2024-09-06: add iris data
status(repo)
#> working directory clean
# remove the data files from the repo
rm_data(repo, path = ".")
# check the removal
list_data(repo)
#> character(0)
status(repo)
#> Unstaged changes:
#> Deleted: iris.tsv
#>
# remove dangling metadata
prune_meta(repo, path = ".")
# check the removal
list_data(repo)
#> character(0)
status(repo)
#> Unstaged changes:
#> Deleted: iris.tsv
#> Deleted: iris.yml
#>