Skip to content

[Bioc-devel] class declaration

8 messages · John Lande, Sean Davis, James W. MacDonald +3 more

#
On Feb 13, 2008 9:44 AM, John Lande <john.lande77 at gmail.com> wrote:
Hi, John.  You need to load Biobase first, as "ExpressionSet" is not
defined.  That should solve the problem.

Sean
#
2008/2/13, John Lande <john.lande77 at gmail.com>:
Define the classes, may be ?
library(Biobase)
is one simple way to do so.


Hoping this helps,


L.
#
Hi John,

 > setClass("my class",representation(a="ExpressionSet", b="ExpressionSet"))
[1] "my class"
Warning message:
In .completeClassSlots(ClassDef, where) :
   undefined slot classes in definition of "my class": a(class 
"ExpressionSet"), b(class "ExpressionSet")


 > library(Biobase)
Loading required package: tools

Welcome to Bioconductor

   Vignettes contain introductory material. To view, type
   'openVignette()'. To cite Bioconductor, see
   'citation("Biobase")' and for packages 'citation(pkgname)'.

Warning message:
package 'Biobase' was built under R version 2.6.1
 > setClass("my class",  representation(a="ExpressionSet", 
b="ExpressionSet"))
[1] "my class"

Best,

Jim
John Lande wrote:

  
    
#
You are not doing anything wrong (almost), but you need to have the 
definitions of ExpressionSet before you can use those: library(Biobase)

However, I do not think it is a very good idea to declare a class with a 
space in its name -- even if R allows that you never know where you are 
going to use this definition and a space is a very particular character 
in most programming languages -- it separates keywords, definitions, 
concepts etc

* ~: R
:: R version 2.6.1 (2007-11-26)
 > library(Biobase)
Loading required package: tools

 > setClass("my class",  representation(a="ExpressionSet", 
b="ExpressionSet"))
[1] "my class"
 >

Best,
Oleg
John Lande wrote:

  
    
#
Ok, now when that works I would like to ask a more general question:

Is it completely safe to have spaces in class declarations?  ...or
function definitions, e.g.
[1] 3

I can definitely see how this increases the risk for
mistakes/misunderstandings.  Is this something that should be
discouraged?

/Henrik
On Feb 13, 2008 6:56 AM, John Lande <john.lande77 at gmail.com> wrote:
#
It can certainly be strongly discouraged, just like variable names
should make sense is encouraged.
The R documentation does not seem to make a special case of it
help("'") will tell more about it.

Out of curiosity, I checked and there does not seem to be default
starting packages with spaces in variable names

unlist(lapply(loadedNamespaces(),
                    function(x) grep(" ", ls(getNamespace(x)))))
returns integer(0) here.

There is more to that than spaces, and the following might give
an idea of what is possible (don't try that at home ;-))
[1] 42


2008/2/14, Henrik Bengtsson <hb at stat.berkeley.edu>: