Reputation: 7575
In S3 style OOP, a function name written as foo.A
is used for calling method foo for class A .
But recently I came across function written as function.class.class
foo.A.B <- function(x){
##---
}
What is this kind of function do?
Upvotes: 2
Views: 55
Reputation: 206242
(Posting as answer to close out the question)
As @joran pointed out, the function fortify.MSM.lm
is actually just a method for the fortify
function for an object of type MSM.lm
. There is no implied heirachy from the use of the period here. The period in R in most cases is just like any other character for naming variables; it does not have the same significance it does in other languages. One of the few exceptions is, as you've already see, naming methods for S3 generic functions.
So you could define
my.fun <- function(x, ...) UseMethod("my.fun")
my.fun.data.frame <- function(x, ...) summary(x)
my.fun(mtcars)
So in the name my.fun.data.frame
. The periods don't mean anything, it's just that when you call my.fun
with a class of data.frame
, R will look for a function called "my.fun" + "." + "data.frame"
.
Upvotes: 4