On 04/11/2021 12:36 p.m., Bert Gunter wrote:
" Running `methods(names)` lists quite a few methods, ..."
Depending on what packages you have loaded of course.
Yes, just one is in a base package.
Duncan Murdoch
__
R-help@r-project.org mailing list
" Running `methods(names)` lists quite a few methods, ..."
Depending on what packages you have loaded of course.
Bert
On Thu, Nov 4, 2021 at 7:43 AM Duncan Murdoch
wrote:
> On 04/11/2021 10:38 a.m., Jorgen Harmse via R-help wrote:
> > Can someone please explain what Leonard Mada is trying to
On 04/11/2021 10:38 a.m., Jorgen Harmse via R-help wrote:
Can someone please explain what Leonard Mada is trying to do? As far as I know,
names is not generic and there is no names.data.frame because it’s not needed.
(A data.frame seems to be just a named list with some extra functionality
Can someone please explain what Leonard Mada is trying to do? As far as I know,
names is not generic and there is no names.data.frame because it’s not needed.
(A data.frame seems to be just a named list with some extra functionality that
depends on every element being a vector with the same
On 03/11/2021 3:42 p.m., Duncan Murdoch wrote:
On 03/11/2021 2:54 p.m., Andrew Simmons wrote:
... deletions ...
As a side note, I would suggest making your class through the methods
package, with methods::setClass("pm", ...)
See the documentation for setClass for more details, it's the
Thank you very much.
Indeed, NextMethod() is the correct way and is working fine.
There are some alternatives (as pointed out). Although I am still trying
to figure out what would be the best design strategy of such a class.
Note:
- I wanted to exclude the "coeff" column from the returned
On 03/11/2021 2:54 p.m., Andrew Simmons wrote:
First, your signature for names.pm is wrong. It should look something more
like:
names.pm <- function (x)
{
}
As for the body of the function, you might do something like:
names.pm <- function (x)
{
NextMethod()
}
but you don't need to
Hello,
I too would expected NextMethod to work but the following seems to be
simpler.
"names" is an attribute, so should be accessible with attr.
names.pm = function(p) {
attr(p, "names")
}
p = data.frame(x=1:3, coeff=1)
class(p) = c("pm", class(p));
names(p)
#[1] "x" "coeff"
On Wed, 3 Nov 2021 20:35:58 +0200
Leonard Mada via R-help wrote:
> class(p) = c("pm", class(p));
Does NextMethod() work for you?
--
Best regards,
Ivan
__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
First, your signature for names.pm is wrong. It should look something more
like:
names.pm <- function (x)
{
}
As for the body of the function, you might do something like:
names.pm <- function (x)
{
NextMethod()
}
but you don't need to define a names method if you're just going to call
Dear List members,
Is there a way to access the default names() function?
I tried the following:
# Multi-variable polynomial
p = data.frame(x=1:3, coeff=1)
class(p) = c("pm", class(p));
names.pm = function(p) {
# .Primitive("names")(p) # does NOT function
# .Internal("names")(p) # does
11 matches
Mail list logo