Hello: Could anyone point me to a nice example where someone has created methods for "[" on a user defined Class? I looked at the package Matrix but that was a little daunting. I'm looking for someone a little more introductory. I've tried to search the help section and the web but its difficult since "[" isn't searchable. Thanks in advance! Greg [[alternative HTML version deleted]]
On Mon, 2007-03-12 at 21:28 -0700, Sender wrote:> Hello: > > Could anyone point me to a nice example where someone has created methods > for "[" on a user defined Class? > > I looked at the package Matrix but that was a little daunting. I'm looking > for someone a little more introductory. I've tried to search the help > section and the web but its difficult since "[" isn't searchable. > > Thanks in advance! > > GregYou might want to look at this thread from last year: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77057.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77060.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77059.html http://finzi.psych.upenn.edu/R/Rhelp02a/archive/77102.html You can also review the existing methods defined for '[' in your current installation by using: methods("[") It may be easiest to then review the code for a given method by using something like the following as an example: getAnywhere("[.data.frame") BTW, for searching the R help files, REGEX's are used, so for "[", you would need: help.search("\\[") since '[' is a special character in regular expressions and you need to escape it to search on the literal character. In R, you need to double the '\' to be interpreted properly. HTH, Marc Schwartz
Le Mardi 13 Mars 2007 00:28, Sender a ?crit?:> Hello: > > Could anyone point me to a nice example where someone has created methods > for "[" on a user defined Class? > > I looked at the package Matrix but that was a little daunting. I'm looking > for someone a little more introductory. I've tried to search the help > section and the web but its difficult since "[" isn't searchable. > > Thanks in advance!You might also have a look at the methods for "[" and "[<-" created for "grouped data" objects in the development version of package actuar. Creation of the objects: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/R/grouped.data.R Extraction methods: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/R/Extract.grouped.data.R Doc: https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/man/grouped.data.Rd https://vgoulet.act.ulaval.ca/svn/R/actuar/trunk/actuar/man/Extract.grouped.data.Rd Package: http://vgoulet.act.ulaval.ca/actuar/ HTH -- Vincent Goulet, Associate Professor ??cole d'actuariat Universit?? Laval, Qu??bec Vincent.Goulet at act.ulaval.ca http://vgoulet.act.ulaval.ca