From luca.cerone at gmail.com  Wed May 14 11:42:02 2014
From: luca.cerone at gmail.com (Luca Cerone)
Date: Wed, 14 May 2014 11:42:02 +0200
Subject: [Rd] [R] S3 - how to implement "colnames<-"
In-Reply-To: <CAAjnpdhA5zQD=Zjr1UL8ofTc6iBbCW3w1VWuidLdQHPsQ3PhBw@mail.gmail.com>
References: <CAAjnpdhA5zQD=Zjr1UL8ofTc6iBbCW3w1VWuidLdQHPsQ3PhBw@mail.gmail.com>
Message-ID: <CAFnz2-_ug2cFf1N_SV+JfQDsSjcu1bCCADHB2QerSipsUbyZbg@mail.gmail.com>

Hi Witold,
you should first of all redefine colnames to use UseMethod.
Then you have to write a colnames.default that uses base::colnames
(so that it does not interfere with existing code and other functions)
and the you can define the method for your class.

I would suggest, though, to use attributes for your object, rather
than risking to mess up the default R function.

Hope it helps,
Cheers,
Luca

2014-05-14 10:57 GMT+02:00 Witold E Wolski <wewolski at gmail.com>:
> Have a class for which I would like to provide a "colnames<-.myclass"
> function so that
>
> colnames(myintsance) <- c("a","b","c")
> can be called.
>
> Witold
>
>
> --
> Witold Eryk Wolski
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Luca Cerone

Tel: +34 692 06 71 28
Skype: luca.cerone



[Rd] [R] S3 - how to implement "colnames<-"
Luca Cerone