Importing a dataset from one package to another

Hi there -

I would like to import an existing dataset (HSAUR::polyps) from an existing package (with its documentation) into a new package.

I tried by creating a file named data_import.R in the R folder,

with one line

#' @importFrom HSAUR polyps

then ran devtools::document()

then did Build/install and restart.

No data_import.Rd file was written to the man folder.

And the dataset is not available in the new package.

Any ideas on how to do this properly (as this clearly is not working)??

thanks for your help!

Load the package lib and then load the data into R and save it with your new filename in the folder. Continue your package development.

library(package)
DATA <- load(dataname)
save(DATA, filename)

1 Like

Will that get me the *.R file (or the .Rd version) with the description, variable names and definitions? I would like to get that as well, not just the data. Is there a way to get the *.R or *.Rd file as well as the data?

I realized you can find this one on Github at https://github.com/cran/HSAUR/tree/master/man
and simply download the *.Rd files.

A 'dumb' workaround, but it works.

Is there a more clever way to use @import, or @importFrom ?

It appears that you can import functions this way.
Can you also import data and *.R and/or *.Rd files?

Just as you said, it is easier to download the data and write your .R codes to use the data as you want. I have not used the import or importFrom functions before.

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.