How to deal with "Warning: object" xxx "is created by more than one data call"

While checking package R, I got a warning

Warning: object 'xxx' is created by more than one data call 

What causes this and how to fix it?

+5
source share
1 answer

This warning occurs when several RData files in the data directory of a package store a variable with the same name.

To reproduce, we create a package and save the cars dataset twice, for different files:

 library(devtools) create("test") dir.create("test/data") save(cars, file = "test/data/cars1.RData") save(cars, file = "test/data/cars2.RData") check("test") 

Exiting check includes the following lines:

The following important warnings were found: Warning: 'cars' objects are created by more than one data call


If you get this warning, you can find duplicate variable names using:

 rdata_files <- dir("test/data", full.names = TRUE, pattern = "\\.RData$") var_names <- lapply( rdata_files, function(rdata_file) { e <- new.env() load(rdata_file, envir = e) ls(e) } ) Reduce(intersect, var_names) ## [1] "cars" 
+5
source

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


All Articles