Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MASS import causes name conflicts (e.g. with select function from dplyr) #12

Open
lapotok opened this issue May 11, 2020 · 1 comment
Open

Comments

@lapotok
Copy link

lapotok commented May 11, 2020

Dear drc developers,

I like your package very much and use it all the time in my work. Also I enjoy using tidyverse metapackage with its pipelines. But there's an issue that prevents me from using both with comfort.
I can see that you are using MASS package for some calculations. Unfortunately, importing all its functions into user environment can cause name conflicts (e.g. select() function from dplyr). Currently I have to manually detach MASS package to keep working normally with select() from dplyr, or explicitly state dplyr::select(), or use drc functions like drc::drm(formula, data, fct = drc::LL.4() ...) to prevent attaching MASS.
I'd suggest to run MASS functions without attaching them, like MASS::boxcox().

Best regards,
Evgeny

@nlubock
Copy link

nlubock commented Mar 31, 2021

I totally agree with your suggestion @lapotok . That said, a quick workaround is to load tidyverse after drc.

Loading tidyverse before drc:

> library(tidyverse)
── Attaching packages ────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.3     ✓ purrr   0.3.4
✓ tibble  3.0.5     ✓ dplyr   1.0.3
✓ tidyr   1.1.2     ✓ stringr 1.4.0
✓ readr   1.3.1     ✓ forcats 0.5.0
── Conflicts ───────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
> library(drc)
Loading required package: MASS

Attaching package: ‘MASS’

The following object is masked from ‘package:dplyr’:

    select


'drc' has been loaded.

Please cite R and 'drc' if used for a publication,
for references type 'citation()' and 'citation('drc')'.


Attaching package: ‘drc’

The following objects are masked from ‘package:stats’:

    gaussian, getInitial


> mtcars %>% 
+     select(mpg)
Error in select(., mpg) : unused argument (mpg)

Loading tidyverse after drc:

> library(drc)
Loading required package: MASS

'drc' has been loaded.

Please cite R and 'drc' if used for a publication,
for references type 'citation()' and 'citation('drc')'.


Attaching package: ‘drc’

The following objects are masked from ‘package:stats’:

    gaussian, getInitial

> library(tidyverse)
── Attaching packages ─────────────────────────────────── tidyverse 1.3.0 ──
✓ ggplot2 3.3.3     ✓ purrr   0.3.4
✓ tibble  3.0.5     ✓ dplyr   1.0.3
✓ tidyr   1.1.2     ✓ stringr 1.4.0
✓ readr   1.3.1     ✓ forcats 0.5.0
── Conflicts ────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks stats::filter()
x dplyr::lag()    masks stats::lag()
x dplyr::select() masks MASS::select()


> mtcars %>% 
+     select(mpg)
                     mpg
Mazda RX4           21.0
Mazda RX4 Wag       21.0
Datsun 710          22.8
Hornet 4 Drive      21.4
Hornet Sportabout   18.7
...

You can see from the conflicts section the the only function tidyverse masks from MASS is select

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants