rticulate / import

An Import Mechanism For R
https://import.rticulate.org
Other
222 stars 14 forks source link

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

Closed chunyunma closed 3 years ago

chunyunma commented 3 years ago

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!

torfason commented 3 years ago

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).