rticulate/import

Use case for "import::from(<pkg>, '<func>', .into = '<group>')"?

chunyunma opened this issue · 1 comments

I came across the import package recently
and finally saw some hope with solving the namespace chaos
in R compared to Python.
Thank you for the great work!
I saw the following example on your website:

# Choosing where the imported functions are placed
import::from(magrittr, "%>%", "%$%", .into = "operators")

Intuitively, it is a very appealing idea, to get things organized.
However, due to my limited knowledge about the inner-workings of R,
I am not sure when & why I will be using this function.
as opposed to importing everything into the same global environment.

Do you mind giving me some example about the use case of this particular function?
Thank you very much!

I'm glad you like the import package!

Using the .into parameter to import into specific named environments is a matter of preference. I don't use it personally but some people may like the ability to look at functions that belong together in a single named environment (Rstudio provides a simple dropdown to look at each such environment).