autogenerate: Autogenerate a datastorr interface

Description Usage Arguments Details Examples

View source: R/autogenerate.R

Description

Autogenerate an datastorr interface for a package. The idea is to run this function and save the resulting code in a file in your package. Then users will be able to download data and you will be able to relase data easily.

Usage

1
2
autogenerate(repo, read, filename = NULL, name = basename(repo),
  roxygen = TRUE)

Arguments

repo

Name of the repo on github (in username/repo format)

read

name of a function to read the data. Do not give the function itself!

filename

Name of the file to read. If not given, then the single file in a release will be read (but you will need to provide a filename on upload). If given, you cannot change the filename ever as all releases will be assumed to have the same filename.

name

Name of the dataset, used in generating the functions. If omitted the repo name is used.

roxygen

Include roxygen headers for the functions?

Details

In addition to running this, you will need to add datastorr to the Imports: section of your DESCRIPTION. To upload files you will need to set your GITHUB_TOKEN environment variable. These steps will be described more fully in a vignette.

More complete instructions:

Let pkg be basename(repo); the name of the package and of the GitHub repository.

First, create a new R package, e.g. devtools::create(pkg).

Then, copy the result of running autogenerate into a file in that package, e.g.

1
2
3
   writeLines(autogenerate(repo, read),
             file.path(pkg, "datastorr.R"))
  devtools::document(pkg)

Create a new git repository for this package, and add all the files in the package, and commit.

On GitHub, create a repository for the package and push your code there.

At this point you are now ready to start making releases by loading your package and running pkg::<name>_release().

Examples

1
2
3
4
5
writeLines(autogenerate("richfitz/datastorr.example",
                        read = "readRDS", name = "mydata"))
writeLines(autogenerate("richfitz/datastorr.example",
                        read = "readRDS", name = "mydata",
                        roxygen = FALSE))

richfitz/dataverse documentation built on July 9, 2021, 12:08 p.m.