knitr::opts_chunk$set( comment = "#>", collapse = TRUE )
Ideally, file collections are generated by passing proper file specifications
in a single call to collate()
. In reality, post-processing of the
file collection objects is sometimes needed. Thus, we support a selected
number of file collection operations.
You can merge file collections after they are collated. This operation returns the union of the files.
library("pkglite") pkg <- system.file("examples/pkg1/", package = "pkglite") fc <- merge( pkg %>% collate(file_root_core()), pkg %>% collate(file_r()), pkg %>% collate(file_r(), file_man()) ) fc
By design, one file collection object only stores metadata of files from a single package. Therefore, merging file collections from different packages will result in an error.
To remove files from a file collection, use prune()
:
fc %>% prune(path = c("NEWS.md", "man/figures/logo.png"))
Only the files matching the exact relative path(s) will be removed.
The prune operation is type-stable. If all files in a file collection are removed, an empty file collection is returned so that it can still be merged with the other file collections.
pkg %>% collate(file_data()) %>% prune(path = "data/dataset.rda")
A file collection might contain files that should almost always be excluded,
such as the files defined in pattern_file_sanitize()
:
pattern_file_sanitize()
You can use sanitize()
to remove such files (if any) from a file collection:
fc %>% sanitize()
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.