Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R import all but a couple of functions

Tags:

package

r

I am working on the upgrade to ggtern to handle ggplot 2.0.X, I need to import the grid package, however, ggplot2 is now exporting arrow and unit functions, which generates warnings when my package is loaded:

Warning messages:
1: replacing previous import by ‘grid::arrow’ when loading ‘ggtern’ 
2: replacing previous import by ‘grid::unit’ when loading ‘ggtern’ 

Is it possible to import the library with the exception of a couple of functions, ie something to the effect of the following might be useful in roxygen:

#' @importAllExcept grid arrow unit

Which should have the same effect as the following, (minus importing arrow and unit):

#' @import grid

Any suggestions?

like image 721
Nicholas Hamilton Avatar asked Oct 30 '22 11:10

Nicholas Hamilton


1 Answers

Currently my best idea is

all <- getNamespaceExports("grid")
paste("@importFrom grid", paste(all[!(all %in% c("arrow", "unit"))], collapse = " ")) 
#[1] "@importFrom grid grid.edit pop.viewport ...

That's obviously not a good solution, but unlike for exports you can't use a regex for imports, i.e., there is no importPatternFrom.

like image 143
Roland Avatar answered Nov 08 '22 13:11

Roland