Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting library priority

I have got function alpha() in packages scales and psych. The default call is scales, but I would like to change it. I want to make psych package higher priority - I mean if I call alpha() I want that R run this function from psych package, not scales.

Of course I know that I can use :: , but I don't want that.

How to do that in a simple way?

like image 741
Tomasz Wojtas Avatar asked Nov 05 '25 02:11

Tomasz Wojtas


1 Answers

Three options:

(1) change the order in which you load the packages:

library(scales)
library(psych)

in this case, alpha refers to psych::alpha

(2) call the function like this:

psych::alpha

(3) load the packages in any order and set the function manually, e.g.

library(psych)
library(scales)
alpha = psych::alpha

in this case, even though you loaded psych before scales, the alpha function refers to psych::alpha

like image 115
adn bps Avatar answered Nov 07 '25 16:11

adn bps



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!