3

Possible Duplicate:
R: Masked Functions

I am using the packages moments and fUnitRoots. Both of them have a function called "kurtosis" (to be more precise, the package fUnitRoots calls the package timeDate which also has the function "kurtosis"). They give very different results, because their formulas is slightly different. I want to use the function skewness from the library moments, but if the two libraries are loaded, the function used is the one from fUnitRoots.

How can I specify from which library I want the given function to be used, without unloading one of the libraries?

Community
  • 1
  • 1
Vivi
  • 4,070
  • 6
  • 29
  • 44
  • duplicates: http://stackoverflow.com/questions/9337716/how-do-i-use-functions-in-one-r-package-masked-by-another-package, http://stackoverflow.com/questions/2842120/masked-functions-in-r, http://stackoverflow.com/questions/4879377/r-masked-functions – GSee Aug 18 '12 at 01:34
  • 1
    You might consider searching before posting. – IRTFM Aug 18 '12 at 02:04
  • @DWin I did search, on google and here, and I even browsed through the suggestions once my question had been written. I am very aware of how unforgiving people here are with duplicate questions, but I had a problem, I needed help, and if I have to be afraid of this type of comment or the closing of my questions, I will no longer use this site. – Vivi Aug 18 '12 at 02:08
  • 1
    @Vivi: I don't know what you used for search terms, but searching for the message, "The following object(s) are masked from" provides several hits on Google, Stack Overflow, rseek.org, etc. I don't think it's unreasonable or unforgiving that people expect you to search for the message, error, or warning before posting. – Joshua Ulrich Aug 18 '12 at 02:14
  • @JoshuaUlrich it might be obvious for you that "masked" is a key word in my question, but it is not obvious to me (and I still don't see the connection). I used the terms "[r] choose library function clash" (and repeated the search without the word clash) and I got nothing on google and hundreds of answers here. If I didn't ask, I wouldn't have found the answer. If the question is a duplicate, close it; I don't take it personally. But I really don't see why the assumption is that I didn't search and why people feel the need to tell me off. – Vivi Aug 18 '12 at 02:24
  • 1
    @Vivi: The only reason it was obvious to me to search for "The following object(s) are masked from" is because that's the message you get when you run `library(moments); library(fUnitRoots)`. I ran the code, it gave me a message, I searched for the message. It's that simple. – Joshua Ulrich Aug 18 '12 at 02:35
  • @JoshuaUlrich I didn't read the messages, and it is fair to say I should have, but I don't think it is fair to assume I was lazy or to be told to search before asking, with the presumption I haven't. This doesn't help. Anyway, thanks for pointing out the message, I will make sure I read the stuff that comes up when packages are loaded. – Vivi Aug 18 '12 at 06:05

1 Answers1

5

Use the :: operator. The syntax is package::name. So it would be moments::kurtosis.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
Luciano Selzer
  • 9,806
  • 3
  • 42
  • 40
  • Perfect! I need to wait 8 minutes to accept, but that solves my problem :) – Vivi Aug 18 '12 at 01:34
  • How can one ask R to always use the function from a particular library in the current workspace? This solution will entail typing the library name and :: each time the function is called. – Sagar Jun 07 '22 at 14:08