s4

Inheritance in R

*爱你&永不变心* 提交于 2019-11-27 06:50:41
With regards to R, Can someone explain to me, with regards to object inheritance, if I have S4 object X, which contains Y, if Y has an initializer, how can that initializer be called from within the initializer of X, when X is constructed. Martin Morgan A first pass, not quite good enough Here are two classes .A <- setClass("A", representation(a="integer")) .B <- setClass("B", contains="A", representation(b="integer")) The symbol .A is a class generator function (essentially a call to new() ), and is a relatively new addition to the methods package. Here we write an initialize,A-method, using

What does the @ symbol mean in R?

元气小坏坏 提交于 2019-11-27 04:22:57
问题 In packages like marray and limma, when complex objects are loaded, they contain "members variables" that are accessed using the @ symbol. What does this mean and how does it differ from the $ symbol? 回答1: See ?'@' : Description: Extract the contents of a slot in a object with a formal (S4) class structure. Usage: object@name ... The S language has two object systems, known informally as S3 and S4. S3 objects, classes and methods have been available in R from the beginning, they are informal,

How to develop a package in R?

本小妞迷上赌 提交于 2019-11-26 23:48:58
问题 I have written some functions in R using S4 classes. Now I want to build an R package out of these functions. How should I proceed? Is there anything that I should do differently because I have used S4 classes? 回答1: Consult the following reference material: Chapter 1, Creating R packages, of the Writing R extensions manual. This is the canonical source. It's the ultimate reference point, but not necessarily the best starting point. A short presentation outlining the key ideas in package

How to properly document S4 class slots using Roxygen2?

我只是一个虾纸丫 提交于 2019-11-26 18:48:47
问题 For documenting classes with roxygen(2), specifying a title and description/details appears to be the same as for functions, methods, data, etc. However, slots and inheritance are their own sort of animal. What is the best practice -- current or planned -- for documenting S4 classes in roxygen2? Due Diligence: I found mention of an @slot tag in early descriptions of roxygen. A 2008 R-forge mailing list post seems to indicate that this is dead, and there is no support for @slot in roxygen: Is

Sources on S4 objects, methods and programming in R

谁说胖子不能爱 提交于 2019-11-26 18:44:48
问题 As I'm often confronted with situations where S4 programming is needed to keep an overview, I've collected quite some sources on S4 objects, methods and programming. I've listed them here as a reference. Please add your own sources as well. On the web The methods help files : help files from the package methods, where much of the necessary information can be found S4 classes in 15 pages : Short introduction on the programming with S4 objects. How S4 methods work : more explanation about the

How to define the subset operators for a S4 class?

旧街凉风 提交于 2019-11-26 17:37:45
问题 I am having trouble figuring out the proper way to define the [ , $ , and [[ subset operators for an S4 class. Can anyone provide me with a basic example of defining these three for an S4 class? 回答1: Discover the generic so that we know what we are aiming for > getGeneric("[") standardGeneric for "[" defined from package "base" function (x, i, j, ..., drop = TRUE) standardGeneric("[", .Primitive("[")) <bytecode: 0x32e25c8> <environment: 0x32d7a50> Methods may be defined for arguments: x, i, j

Inheritance in R

一世执手 提交于 2019-11-26 12:12:38
问题 With regards to R, Can someone explain to me, with regards to object inheritance, if I have S4 object X, which contains Y, if Y has an initializer, how can that initializer be called from within the initializer of X, when X is constructed. 回答1: A first pass, not quite good enough Here are two classes .A <- setClass("A", representation(a="integer")) .B <- setClass("B", contains="A", representation(b="integer")) The symbol .A is a class generator function (essentially a call to new() ), and is