Data not exported from namespace to R

I tuned and regularly updated my R package to GitHub after Hadley's extensive documentation on Devtools, Roxygen2, etc. on my laptop. Yesterday I decided to use my main computer instead, and now I want to push the changes to GitHub. After entering document() I got the following error:

 Error: 'Adult_Females' is not an exported object from 'namespace:gbm.auto' 

Adult_Females is the name of the first data file in / Data. According to this (scroll down to "Data")

"that live in data / donโ€™t use the usual namespace mechanism and donโ€™t need to export."

So ... what to do? I have not edited Adult_Females in any way, and the R script I edited does not reference it. My suspicion is that this error will appear for all data files, and it just happened that this is the first of them, but this hypothesis is at the moment.

Thanks in advance. install_github("SimonDedman/gbm.auto") if you want to watch.

+5
source share
2 answers

I ran into a similar problem when writing an R package that contains a dataset. I think you must have saved the dataset under a different name. For example, you can write:

 devtools:::use_data(YourDataSetName, pkg = "Path_to_Pkg/data", internal=FALSE) 

but in your data.R file you specified the name of the dataset at the very end , except YourDataSetName (suppose you followed Hadley's instructions: http://r-pkgs.had.co.nz/data.html ). Make sure that the data object that you saved in the data folder matches the one specified in your data.R file.

+4
source

for data objects, the names must match in four (4) places, so check all of them:

  • file name data / foo.rda
  • the name of the object in the data / foo.rda file
  • file name R / foo.R
  • line at the end of the R / foo.R file

all four elements must match - in this case "foo". If you change the names of the files foo.rda and foo.R to, say, bar.rda and bar.R, it is easy to forget to rename the object in the .rda file from "foo" to "bar". Itโ€™s usually easier to upload a file, rename the object and save the file with a new name:

 load('data/foo.rda') bar <- foo save(bar, file='data/bar.rda') 

If you do not, you will get a useless error about an object not loaded from the namespace. You do NOT need @export data objects, so instead the names must match in all places.

+1
source

Source: https://habr.com/ru/post/1259112/


All Articles