I defined an SV4 class and a constructor as follows:
> setClass("md",prototype=0.0)
> md<-function(x) new("md",x/12)
I would like the concatenation function to return an object of class
'md'. For example, I would like
> c(md(12),md(24))
to return
An object of class "md"
[1] 1 2
When I try
> setMethod("c","md",function(...,recursive=F)
> {md(do.call("c",lapply(list(...),unclass)))})
I get
Warning messages:
1: a function definition of "c" exists on database "splus"
inconsistent with the new generic definition in: assignMethods(f,
methods, where)
2: Conflicting definitions of "c" on databases
"C:\Users\Owner\DOCUME~1\SPOTFI~1\Project1" and "splus" in: assign(f,
what@genericDef, where = where)
Warning messages:
1: a function definition of "c" exists on database "splus"
inconsistent with the new generic definition in: assignMethods(f,
methods, where)
2: Conflicting definitions of "c" on databases
"C:\Users\Owner\DOCUME~1\SPOTFI~1\Project1" and "splus" in: assign(f,
what@genericDef, where = where)
Problem in c(generics, f): No method found for "c"
Error during wrapup: 2:
... and the "c" function disappears!
> c
Problem in c("bdCharacter", "bdExclude", "bdFactor", "bdFrame",
"bdInternalCache", "bdLogica..: No method found for "c"
Error during wrapup: No method found for "c"
I tried different arguments for "function" -- (...),
(x,...,recursive=F), (x,...) -- but all led to the same result.
Clearly I'm doing something very basically wrong, but cannot figure
out what it is by reading the "Programmer's Guide" and other online
manuals. Could someone please point me in the right direction? Thank
you.
-Dan
|