Re: [Rd] R 2.5.0 devel try issue in conjuntion with S4 method dispatch

2007-03-16 Thread Martin Maechler

> "PD" == Peter Dalgaard <[EMAIL PROTECTED]>
> on Fri, 16 Mar 2007 08:09:00 +0100 writes:

PD> Seth Falcon wrote:
>> [EMAIL PROTECTED] writes:
>> 
>>> Investigating this new implementation I come across an issue in
>>> conjuntion with using S4 classes and methods. try(expr) does not return 
an
>>> object with attribute 'try-error' in case of method dispatch failure
>>> in the wrapped expression which to me seems not
>>> quite correct.
>>> 
>> 
>> We've seen some similar issues but had not had time to track them
>> down.
>> 
>> 
>>> Examples to reproduce the observation:
>>> 
>> 
>> It isn't S4 specific.  The issue seems more about anonymous
>> calls/functions.
>> 
>> ll = list()
>> ll[[1]] = function(x) stop("died")
>> 
>> v = try(do.call(ll[[1]], list(1)), silent=TRUE)
>> Error in as.list(call)[[1]] == "doTryCatch" : 
>> comparison (1) is possible only for atomic and list types
>> > v
>> Error: object "v" not found
>> 
>> I don't fully understand why the call is being computed, but the
>> following seems to get things going.
>> 
>> + seth
>> 
>> --- a/src/library/base/R/New-Internal.R
>> +++ b/src/library/base/R/New-Internal.R
>> @@ -7,7 +7,8 @@ try <- function(expr, silent = FALSE) {
>> ## Patch up the call to produce nicer result for testing as
>> ## try(stop(...)).  This will need adjusting if the
>> ## implementation of tryCatch changes.
>> -if (as.list(call)[[1]] == "doTryCatch")
>> +callFun <- as.list(call)[[1]]
>> +if (is.name(callFun) && callFun == "doTryCatch")
>> call <- sys.call(-4)
>> dcall <- deparse(call)[1]
>> prefix <- paste("Error in", dcall, ": ")
>> 
>> 
PD> Good catch, Seth. 

yes, indeed!

PD> The code still looks a bit clunky though, and I wonder 
PD> if this wouldn't be nicer:

PD> if (identical(call[[1]], quote(doTryCatch))) call <- sys.call(-4)

PD> I.e., the thing that is clearly wrong is the use of "==" on something 
PD> that is not necessarily a simple name, but the use of as.list seems 
PD> unnecessary and comparisons between strings and names is a bit awkward 
too.

Indeed, I had similar thoughts when reading the part of code
Seth was patching 
{ but would have used the old-fashioned   as.name("doTryCatch")
  instead of the modern  quote(doTryCatch)
  for the only reason that I'm probably slightly ``older fashioned''
  than Peter  ;-)  
}

Martin

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Unhidden predict methods

2007-03-16 Thread Henric Nilsson (Public)
Hi,

I've noted that not all `predict' methods are hidden in the namespace:

 > methods("predict")
  [1] predict.ar*predict.Arima*
  [3] predict.arima0*predict.glm
  [5] predict.HoltWinters*   predict.lm
  [7] predict.loess* predict.mlm
  [9] predict.nls*   predict.poly
[11] predict.ppr*   predict.prcomp*
[13] predict.princomp*  predict.smooth.spline*
[15] predict.smooth.spline.fit* predict.StructTS*

Non-visible functions are asterisked

I'm sure there's a good reason for this, but I haven't been able to 
figure it out. Please enlighten me.

Thanks!


Henric

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Unhidden predict methods

2007-03-16 Thread Henrik Bengtsson
One reason is that you should never call those methods directly but
only via the generic function predict(), and this is a way to prevent
such misuse/mishaps.  You can always use getAnywhere() if you want
look at the code.

/H

On 3/16/07, Henric Nilsson (Public) <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've noted that not all `predict' methods are hidden in the namespace:
>
>  > methods("predict")
>   [1] predict.ar*predict.Arima*
>   [3] predict.arima0*predict.glm
>   [5] predict.HoltWinters*   predict.lm
>   [7] predict.loess* predict.mlm
>   [9] predict.nls*   predict.poly
> [11] predict.ppr*   predict.prcomp*
> [13] predict.princomp*  predict.smooth.spline*
> [15] predict.smooth.spline.fit* predict.StructTS*
>
> Non-visible functions are asterisked
>
> I'm sure there's a good reason for this, but I haven't been able to
> figure it out. Please enlighten me.
>
> Thanks!
>
>
> Henric
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Unhidden predict methods

2007-03-16 Thread Prof Brian Ripley
The reason some are not hidden is historical: they were called explicitly 
by (contributed) package code at the time namespaces were introduced.

It would be a good idea to revisit some of those decisions, but it is not 
a very appealing way to spend one's time.

On Fri, 16 Mar 2007, Henric Nilsson (Public) wrote:

> Hi,
>
> I've noted that not all `predict' methods are hidden in the namespace:
>
> > methods("predict")
>  [1] predict.ar*predict.Arima*
>  [3] predict.arima0*predict.glm
>  [5] predict.HoltWinters*   predict.lm
>  [7] predict.loess* predict.mlm
>  [9] predict.nls*   predict.poly
> [11] predict.ppr*   predict.prcomp*
> [13] predict.princomp*  predict.smooth.spline*
> [15] predict.smooth.spline.fit* predict.StructTS*
>
>Non-visible functions are asterisked
>
> I'm sure there's a good reason for this, but I haven't been able to
> figure it out. Please enlighten me.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] allocVector reference

2007-03-16 Thread Prof Brian Ripley
I believe your assertions are incorrect about both '=' and when copying is 
done.

'=' is neither old nor deprecated and is syntactically different from 
'<-', but where it means assignment, it invokes the same internal code as 
'<-'.

R maintains a call-by-value illusion, but it does not actually copy on 
assignment: Like evaluation, copying on assignment is lazy.  Matthew's 
comment is not the whole story, as x <- y copies if _either_ x or y is 
changed by e.g. subassignment.

Nowadays there is an 'R Internals' manual which explains a great deal of 
how things actually work.  In particular the SEXTYPEs ENVSXP, EXTPTRSXP 
and WEAKREFSXP have different assignment semantics to the others, and it 
explains how the NAMED macros work.

I do not believe you can do in R what Matthew asked: the various reference 
approaches do not return objects that the internal code will handle as if 
they were atomic vectors.  And one has always to remember that the two 
class systems are very largely implemented at interpreted level: internal 
code will often ignore classes (although not as often as it once did).

On Thu, 15 Mar 2007, Andrew Piskorski wrote:

> On Wed, Mar 14, 2007 at 05:44:04PM -, Matthew Dowle wrote:
>>
>> Hi,
>>
>> I'm trying to write a function to return an R vector which points
>> directly to a contiguous subset of another vector, without taking a
>> copy.
>
> Matthew, I don't know the answer to your question, but this all seems
> related to support for references in R.  I've included my notes on R
> references below.
>
> Ah, I think Jens Oehlschlaegel's "ref" package is what you want:
>
>  http://tolstoy.newcastle.edu.au/R/packages/04/0008.html
>
>  Class refdata is a transparent wrapper to matrices and data.frames
>  which allows for memory efficient nested subsetting. I.e. you can
>  create a subset of a subset ... of a data.frame without duplicating
>  the data in memory, instead only indexing information is duplicated.
>
>> Since SEXPREC is a header followed by the data, rather than the

Actually, that is a VECTOR_SEXPREC, used for the vector types.

>> header plus a pointer to the data, I'm not sure what I'm trying to
>> do is possible.  Is there a way of doing this?  Similar in spirit to
>> how the R assignment "x=y" does not copy y until x is modified,
>
> Is you last statement above in fact true?  I was under the impression
> that R does NOT do copy on write, that when you make a copy of a
> variable, R immediately allocates memory and makes a deep copy of the
> value.
>
> But you're using old deprecated "=" for assignment, which is weird, so
> maybe you mean when you pass named arguments to a function?  Function
> args are evaluated lazily, and I think that is used (I don't know how
> exactly) to give copy on write behavior - but only for function
> arguments.
>
> My (older) notes on R references:
>
> R does not support reference variables and does not do copy on write -
> when you copy a variable, it eagerly allocates all memory and makes a
> deep copy.  (I believe S-Plus has the same behavior but have not
> checked.)  This can be annoying...
>
> There are however specific exceptions.  For example, R environments
> are treated as references, NOT values like most everything else in R.
> The July 2006 "attributes of environments" thread makes that clear:
>
>  https://stat.ethz.ch/pipermail/r-devel/2006-July/038352.html
>
> Jens Oehlschlaegel's ref package implements references for both R and
> S-Plus:
>
>  http://cran.r-project.org/src/contrib/Descriptions/ref.html
>  http://www.maths.lth.se/help/R/.R/library/ref/html/00Index.html
>  http://tolstoy.newcastle.edu.au/~rking/R/packages/04/0008.html
>
> Henrik Bengtsson's R.oo package emulates reference variables via R
> environments (but perhaps only in the context of his OO framework, I'm
> not sure).
>
>  http://www.braju.com/R/
>  http://cran.r-project.org/src/contrib/Descriptions/R.oo.html
>  http://www.maths.lth.se/help/R/R.oo/
>
> Bengtsson also wrote a 2002 paper, "Implementing support for
> references in R":
>
>  http://www.maths.lth.se/help/R/ImplementingReferences/
>
> Further out, see also Tierny's (mostly old) R development notes
>
>  Notes on References, External Objects, or Mutable State for R:
>http://www.stat.uiowa.edu/~luke/R/references.html
>  Simple References with Finalization:
>http://www.stat.uiowa.edu/~luke/R/simpleref.html
>  Finalization and Weak References in R:
>http://www.stat.uiowa.edu/~luke/R/references/weakfinex.html
>
>

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Unhidden predict methods

2007-03-16 Thread Henric Nilsson (Public)
Den 2007-03-16 13:25, Prof Brian Ripley skrev:

> The reason some are not hidden is historical: they were called 
> explicitly by (contributed) package code at the time namespaces were 
> introduced.

Ah, I see.

In that case I'll just hide away as much as possible in the new package 
I'm working on.

> It would be a good idea to revisit some of those decisions, but it is 
> not a very appealing way to spend one's time.

Agreed.

Thanks again!


Henric



> 
> On Fri, 16 Mar 2007, Henric Nilsson (Public) wrote:
> 
>> Hi,
>>
>> I've noted that not all `predict' methods are hidden in the namespace:
>>
>> > methods("predict")
>>  [1] predict.ar*predict.Arima*
>>  [3] predict.arima0*predict.glm
>>  [5] predict.HoltWinters*   predict.lm
>>  [7] predict.loess* predict.mlm
>>  [9] predict.nls*   predict.poly
>> [11] predict.ppr*   predict.prcomp*
>> [13] predict.princomp*  predict.smooth.spline*
>> [15] predict.smooth.spline.fit* predict.StructTS*
>>
>>Non-visible functions are asterisked
>>
>> I'm sure there's a good reason for this, but I haven't been able to
>> figure it out. Please enlighten me.
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Unhidden predict methods

2007-03-16 Thread Gabor Grothendieck
Sometimes its useful to call a method on a class other than the method
indicated by the suffix of the method name and in that case one needs
to call the method directly rather than via the generic.

For an example, see:

http://tolstoy.newcastle.edu.au/R/e2/help/07/01/9383.html


On 3/16/07, Henric Nilsson (Public) <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've noted that not all `predict' methods are hidden in the namespace:
>
>  > methods("predict")
>  [1] predict.ar*predict.Arima*
>  [3] predict.arima0*predict.glm
>  [5] predict.HoltWinters*   predict.lm
>  [7] predict.loess* predict.mlm
>  [9] predict.nls*   predict.poly
> [11] predict.ppr*   predict.prcomp*
> [13] predict.princomp*  predict.smooth.spline*
> [15] predict.smooth.spline.fit* predict.StructTS*
>
>Non-visible functions are asterisked
>
> I'm sure there's a good reason for this, but I haven't been able to
> figure it out. Please enlighten me.
>
> Thanks!
>
>
> Henric
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R 2.5.0 devel try issue in conjuntion with S4 method dispatch

2007-03-16 Thread Seth Falcon
This is off-topic, but since the discussion moved towards coding
style...  Here are some comments on S4 style.

[EMAIL PROTECTED] writes:
> ##  using S4 classes and methods
> setClass("fooBase",
>  representation("VIRTUAL",
> width  = "numeric",
> height = "numeric"),
>  prototype(width  = 1024,
>height = 1024),
>  validity = NULL,
>  where= .GlobalEnv,
>  sealed   = TRUE,
>  )

I think for package code, you don't want to specify the where to be
.GlobalEnv.  If you omit the where argument, the class will be defined
within the package environment which is what one usually wants.


> if (!isGeneric("plotObject")) {
>
>   setGeneric("plotObject",
>  def=function(x, y, ...) {
>value <- standardGeneric("plotObject")
>return(value)
>  },
>  where=.GlobalEnv,
>  useAsDefault=TRUE
>  )
> }

This idiom of conditionally defining an S4 generic is wide-spread and
I suspect was required at some point in time.  However, at this point,
I don't understand why one would do this and it seems that it can only
lead to hard to catch bugs.  I think it should be strongly discouraged.

To define a method on a generic, you need to know what that generic
is.  For example, you need to know the names of the formal arguments.
With conditional definition as above, you risk attempting to define a
method on a generic you know nothing about.

If you want your own generic, define it.  If you want to set a method
on someone else's generic, say so.  For example, you can do:

   setMethod(otherPkg::theirGeneric, ...)

> plotObject.foo <- function(x, y) {
>   plot(x,y)
> }
>
> setMethod("plotObject", signature=c("foo", "numeric"), plotObject.foo,
> where=.GlobalEnv)

This code is a bit confusing to read since an S3 method for class
"foo" and S3 generic plotObject would be plotObject.foo.  Maybe not
worth worrying about.

Finally, a further subtle point about how the generic was defined in
your example code.  Especially for a standardGeneric, it is best not
to name the result before returning as this can affect when results
get copied.  Here's an illustration:

   setGeneric("frob1", function(x) {
   value <- standardGeneric("frob1")
   value
   })
   
   setGeneric("frob2", function(x) {
   standardGeneric("frob2")
   })
   
   setMethod("frob1", "integer",
 function(x) vector(mode="integer", length=x))
   
   setMethod("frob2", "integer",
 function(x) vector(mode="integer", length=x))


   ###
   
   x1 <- frob1(5L)
   > tracemem(x1)
   [1] "<0x3de8098>"
   > x1[1L] <- 5L
   tracemem[0x3de8098 -> 0x3de80d0]: 
   > 
   > x2 <- frob2(5L)
   > tracemem(x2)
   [1] "<0x3de8140>"
   > x2[1L] <- 5L

Best Wishes,

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Inherited S4 methods

2007-03-16 Thread Seth Falcon
cstrato <[EMAIL PROTECTED]> writes:
> I have a variation of this question:
> Is it possible to use the same function name, e.g. "myfunction" in both, 
> an S4
> baseClass and derivedClass. The method "myfunction" in derivedCalss should
> extend the functionality defined in baseClass, analogously to C++ methods.
> If this is possible, does there exist an example?

The S4 object system is generic function based.  Methods are not
contained inside classes.

You can define a generic 'myfunction' and then define methods for
BaseClass and DerivedClass.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Invalidating inaccessible SEXP?

2007-03-16 Thread Martin Morgan
Is there a (C or R) function to invalidate the relevant parts of SEXP
/ data that are inaccessible? My problem is in tracking down
protection and other memory mismanagement bugs, where I have to rely
on luck to invalidate or overwrite data to trigger a detectable
error. This makes it hard to track down a bug (it sometimes doesn't
occur), or to know that a patch fixes the problem.

Thanks,

Martin
-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Incomplete valgrind instrumentation level documentation

2007-03-16 Thread Martin Morgan
The 'Writing R Extensions' manual, configure.ac, and the comment at
the top of memory.c suggests that there are valgrind instrumentation
levels 0, 1, 2 but I think the actual code has four levels.

   level 0 is no additional instrumentation

   level 1 marks uninitialized numeric, logical, integer vectors
   and R_alloc memory

   level 2 marks free memory (DATAPTR, STRING_PTR) and the protection
   stack as inaccessible

   level 3 marks SEXP as inaccessible
-- 
Martin Morgan
Bioconductor / Computational Biology
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] compile 2.4.1 for linux on power cpus SOLVED

2007-03-16 Thread Andrew Ferris
Thank you Ei-ji, 

That seems to have done it.

> .Machine$sizeof.pointer
[1] 8

So in total I've done the following to get it work:

Installed these readline rpms from the SLES10 media:

readline-devel-64bit-5.1-24.4
readline-devel-5.1-24.4

This is the configure command:

./configure CC="gcc -m64" /
CXX="gxx -m64" /
F77="gfortran -m64" / 
FC="gfortran -m64" /
CFLAGS="-mminimal-toc -fno-optimize-sibling-calls -g -O2" /
FFLAGS="-mminimal-toc -fno-optimize-sibling-calls -g -O2" /
LDFLAGS=-L/usr/lib64 /
--without-x

which gets this:

R is now configured for powerpc64-unknown-linux-gnu

  Source directory:  .
  Installation directory:/usr/local

  C compiler:gcc -m64 -std=gnu99  -mminimal-toc 
-fno-optimize-sibling-calls -g -O2
  Fortran 77 compiler:   gfortran -m64  -mminimal-toc 
-fno-optimize-sibling-calls -g -O2

  C++ compiler:  gxx -m64
  Fortran 90/95 compiler:gfortran -m64 -g -O2

  Interfaces supported:
  External libraries:readline
  Additional capabilities:   iconv, MBCS, NLS
  Options enabled:   shared BLAS, R profiling

  Recommended packages:  yes

configure: WARNING: I could not determine CXXPICFLAGS.
configure: WARNING: I could not determine SHLIB_CXXLDFLAGS
configure: WARNING: I could not determine CXXPICFLAGS.
configure: WARNING: you cannot build DVI versions of the R manuals
configure: WARNING: you cannot build PDF versions of the R manuals
configure: WARNING: I could not determine a PDF viewer

And that gets through make with no errors. That's R 2.4.1 on SLES10 on a power5 
CPU server. 

Thank-you to Peter Dalgaard and Prof. Ripley for their help with this.

Andrew Ferris
Network Support Analyst
iCAPTURE Research Centre
University of British Columbia

>>> "Ei-ji Nakama" <[EMAIL PROTECTED]> 3/15/2007 7:01 PM >>>
2007/3/16, Andrew Ferris <[EMAIL PROTECTED]>:
> I'm closer but still not quite there. Here's the configure command I'm using:
>
>  ./configure 'CC=gcc -m64' 'CXX=g++ -m64 -mminimal-toc' 'FC=gfortran -mc64 
> -fno-optimize-sibling-calls' 'F77=gfortran -m64 -fno-optimize-sibling-calls' 
> 'LDFLAGS=-L/usr/lib64' R_PAPERSIZE='letter'

$ uname -a
Linux macg5 2.6.18-3-powerpc64 #1 SMP Mon Dec 4 15:40:16 CET 2006
ppc64 GNU/Linux

$ gcc -v
Using built-in specs.
Target: powerpc-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-mpfr --disable-softfloat
--enable-targets=powerpc-linux,powerpc64-linux --with-cpu=default32
--enable-checking=release powerpc-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

$ gcc -print-multi-lib
.;@[EMAIL PROTECTED]
64;@[EMAIL PROTECTED]@mstrict-align

$ ./configure CC="gcc -m64" \
   CXX="gxx -m64" \
   F77="gfortran -m64" \
   FC="gfortran -m64" \
   CFLAGS="-mminimal-toc -fno-optimize-sibling-calls -g -O2" \
   FFLAGS="-mminimal-toc -fno-optimize-sibling-calls -g -O2" \
   --without-x

$ file bin/exec/R
bin/exec/R: ELF 64-bit MSB executable, PowerPC 64-bit or cisco 7500,
version 1 (SYSV), for GNU/Linux 2.6.0, dynamically linked (uses shared
libs), for GNU/Linux 2.6.0, not stripped

-- 
EI-JI Nakama  <[EMAIL PROTECTED]>
"\u4e2d\u9593\u6804\u6cbb"  <[EMAIL PROTECTED]>



***CONFIDENTIALITY NOTICE***
This electronic message is intended only for the use of the addressee and may 
contain information that is privileged and confidential.  Any dissemination, 
distribution or copying of this communication by unauthorized individuals is 
strictly prohibited. If you have received this communication in error, please 
notify the sender immediately by reply e-mail and delete the original and all 
copies from your system.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] NextMethod and $.myclass

2007-03-16 Thread Gabor Grothendieck
The following redefines $ on "myclass" objects so that it looks up
the concatenation of the unevaluated second argument and 2
in the object and returns the result:

"$.myclass" <- function(x, name) x[[paste(substitute(name), 2, sep = "")]]

# test
myobject <- structure(list(x2 = 3), class = "myclass")
myobject$x # 3

The above worked as desired but now I want to rewrite $.myclass so that
it continues to work the same way but uses NextMethod
to get the next $ method where the remaining work is done. The problem
involves the fact that $ does not evaluate name.   Can this still be done
somehow?

"$.myclass" <- function(x, name) {
modified.name <- paste(substitute(name), 2, sep = "")
# ???
NextMethod()
}

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Inherited S4 methods

2007-03-16 Thread cstrato
Dear Seth

Thank you, maybe I still do not understand S4 methods.

I thought that the purpose of function "callNextMethod()" is to allow
some kind of inheritance. In the Bioconuductor packages which are
using S4, it is only used for method("initialize") but I thought, that
it can be used with every method "mymethod()", is this correct?

Best regards
Christian

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato

Dear all,

Currently, I am trying to create a test package "testS4" using S4 classes,
which I am attaching.

Running R CMD check gives the following error:

coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD check 
testS4_0.1.1.tar.gz

* checking for working latex ...sh: line 1: latex: command not found
NO
* using log directory '/Volumes/CoreData/CRAN/testS4.Rcheck'
* using R version 2.5.0 Under development (unstable) (2007-02-26 r40806)
* checking for file 'testS4/DESCRIPTION' ... OK
* this is package 'testS4' version '0.1.1'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking whether package 'testS4' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking for sufficient/correct file permissions ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... ERROR
Error in library.dynam(lib, package, package.lib) :
   shared library 'testS4' not found
Error: package/namespace load failed for 'testS4'
Execution halted

Can someone explain what this error means?
What is meant with "shared library"?

For another test package I get the following error
coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD INSTALL -l 
~/Library/R/library mytest_0.3.2.tar.gz

* Installing *source* package 'mytest' ...
** R
** save image
Error in setMethod("export", "derivedClass", export.derivedClass) :
   no existing definition for function "export"
Error: unable to load R code in package 'mytest'
Execution halted

This error is even more strange since I cannot reproduce it in the 
attached package.

What may be the reason for this error?

Thank you in advance.
Best regards
Christian
_._._._._._._._._._._._._._._._
C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
V.i.e.n.n.a   A.u.s.t.r.i.a
_._._._._._._._._._._._._._._._



testS4_0.1.1.tar.gz
Description: GNU Zip compressed data
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread Benilton Carvalho
your namespace probably contains:

useDynLib(testS4)

but you don't have any compiled code...

remove that line and everything will be fine.

btw, if you're playing with S4, you must import 'methods'

b

On Mar 16, 2007, at 4:55 PM, cstrato wrote:

> Dear all,
>
> Currently, I am trying to create a test package "testS4" using S4  
> classes,
> which I am attaching.
>
> Running R CMD check gives the following error:
>
> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD check  
> testS4_0.1.1.tar.gz
> * checking for working latex ...sh: line 1: latex: command not found
> NO
> * using log directory '/Volumes/CoreData/CRAN/testS4.Rcheck'
> * using R version 2.5.0 Under development (unstable) (2007-02-26  
> r40806)
> * checking for file 'testS4/DESCRIPTION' ... OK
> * this is package 'testS4' version '0.1.1'
> * checking package dependencies ... OK
> * checking if this is a source package ... OK
> * checking whether package 'testS4' can be installed ... OK
> * checking package directory ... OK
> * checking for portable file names ... OK
> * checking for sufficient/correct file permissions ... OK
> * checking DESCRIPTION meta-information ... OK
> * checking top-level files ... OK
> * checking index information ... OK
> * checking package subdirectories ... OK
> * checking R files for non-ASCII characters ... OK
> * checking R files for syntax errors ... OK
> * checking whether the package can be loaded ... ERROR
> Error in library.dynam(lib, package, package.lib) :
>shared library 'testS4' not found
> Error: package/namespace load failed for 'testS4'
> Execution halted
>
> Can someone explain what this error means?
> What is meant with "shared library"?
>
> For another test package I get the following error
> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD INSTALL -l ~/ 
> Library/R/library mytest_0.3.2.tar.gz
> * Installing *source* package 'mytest' ...
> ** R
> ** save image
> Error in setMethod("export", "derivedClass", export.derivedClass) :
>no existing definition for function "export"
> Error: unable to load R code in package 'mytest'
> Execution halted
>
> This error is even more strange since I cannot reproduce it in the  
> attached package.
> What may be the reason for this error?
>
> Thank you in advance.
> Best regards
> Christian
> _._._._._._._._._._._._._._._._
> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a   A.u.s.t.r.i.a
> _._._._._._._._._._._._._._._._
>
> 
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Incorrect matrix of spearman correlations .... in 64-bit Linux ... (PR#9568)

2007-03-16 Thread vobolonkin
Full_Name: Vladimir Obolonkin
Version: tested in 2.0 to 2.4.1
OS: linux, win, mac
Submission from: (NULL) (202.14.96.194)

{{ Subject shortened manually -- to pass anti-spam filters 

   Original-subject: Incorrect matrix of spearman correlations working \
 large (24000 by 425 and 78 by 425 data frames)  in 64-bit Linux machines;\
  the same code gives correct results in 32-bits Win and Mac (PR#9568)
}}

cc_s<-cor(phenos,vec,method="spearman",use="pairwise.complete.obs")

this is a line copied from real script producing different results in 64
bit/Linux/R (wrong) and Mac&Win (correct)

The script was implemented on 4 machines with Linux 64, Suse 9-10, in 5 variants
of R -- versions from 2.3 to 2.4.1, compiled with few different settings of
optimization and 2 versions of compilers. In all cases the results of spearman
correlation were identical, but wrong.

The same script was started up to 10 times in Win32 on Intel and Linux32 on Mac
with the Rs from 2.3 to 2.4.1 -- in this set of cases the results were identical
and correct.

'phenos' and 'vec' are data frames of 425x78 and 425x24128 respectively, all
numeric variables. The 'phenos' has moderate number of NAs in some columnes.

The problem dissapeared when trying to reduce the size of matrices (by selection
of rows and/or columns) and/or when simulating the data with random generators.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato
Dear Benilton

Thank you, now my package works.

Do you have an explanation for my second problem:

* Installing *source* package 'mytest' ...
** R
** save image
Error in setMethod("export", "derivedClass", export.derivedClass) :
no existing definition for function "export"
Error: unable to load R code in package 'mytest'
Execution halted

What may be the reason for this error?

Best regards
Christian


Benilton Carvalho wrote:
> your namespace probably contains:
>
> useDynLib(testS4)
>
> but you don't have any compiled code...
>
> remove that line and everything will be fine.
>
> btw, if you're playing with S4, you must import 'methods'
>
> b
>
> On Mar 16, 2007, at 4:55 PM, cstrato wrote:
>
>> Dear all,
>>
>> Currently, I am trying to create a test package "testS4" using S4 
>> classes,
>> which I am attaching.
>>
>> Running R CMD check gives the following error:
>>
>> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD check 
>> testS4_0.1.1.tar.gz
>> * checking for working latex ...sh: line 1: latex: command not found
>> NO
>> * using log directory '/Volumes/CoreData/CRAN/testS4.Rcheck'
>> * using R version 2.5.0 Under development (unstable) (2007-02-26 r40806)
>> * checking for file 'testS4/DESCRIPTION' ... OK
>> * this is package 'testS4' version '0.1.1'
>> * checking package dependencies ... OK
>> * checking if this is a source package ... OK
>> * checking whether package 'testS4' can be installed ... OK
>> * checking package directory ... OK
>> * checking for portable file names ... OK
>> * checking for sufficient/correct file permissions ... OK
>> * checking DESCRIPTION meta-information ... OK
>> * checking top-level files ... OK
>> * checking index information ... OK
>> * checking package subdirectories ... OK
>> * checking R files for non-ASCII characters ... OK
>> * checking R files for syntax errors ... OK
>> * checking whether the package can be loaded ... ERROR
>> Error in library.dynam(lib, package, package.lib) :
>>shared library 'testS4' not found
>> Error: package/namespace load failed for 'testS4'
>> Execution halted
>>
>> Can someone explain what this error means?
>> What is meant with "shared library"?
>>
>> For another test package I get the following error
>> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD INSTALL -l 
>> ~/Library/R/library mytest_0.3.2.tar.gz
>> * Installing *source* package 'mytest' ...
>> ** R
>> ** save image
>> Error in setMethod("export", "derivedClass", export.derivedClass) :
>>no existing definition for function "export"
>> Error: unable to load R code in package 'mytest'
>> Execution halted
>>
>> This error is even more strange since I cannot reproduce it in the 
>> attached package.
>> What may be the reason for this error?
>>
>> Thank you in advance.
>> Best regards
>> Christian
>> _._._._._._._._._._._._._._._._
>> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
>> V.i.e.n.n.a   A.u.s.t.r.i.a
>> _._._._._._._._._._._._._._._._
>>
>> 
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Incorrect matrix of spearman correlations .... in 64-bit Linux ... (PR#9568)

2007-03-16 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote:
> Full_Name: Vladimir Obolonkin
> Version: tested in 2.0 to 2.4.1
> OS: linux, win, mac
> Submission from: (NULL) (202.14.96.194)
>
> {{ Subject shortened manually -- to pass anti-spam filters 
>
>Original-subject: Incorrect matrix of spearman correlations working \
>  large (24000 by 425 and 78 by 425 data frames)  in 64-bit Linux 
> machines;\
>   the same code gives correct results in 32-bits Win and Mac (PR#9568)
> }}
>
> cc_s<-cor(phenos,vec,method="spearman",use="pairwise.complete.obs")
>
> this is a line copied from real script producing different results in 64
> bit/Linux/R (wrong) and Mac&Win (correct)
>
> The script was implemented on 4 machines with Linux 64, Suse 9-10, in 5 
> variants
> of R -- versions from 2.3 to 2.4.1, compiled with few different settings of
> optimization and 2 versions of compilers. In all cases the results of spearman
> correlation were identical, but wrong.
>
> The same script was started up to 10 times in Win32 on Intel and Linux32 on 
> Mac
> with the Rs from 2.3 to 2.4.1 -- in this set of cases the results were 
> identical
> and correct.
>
> 'phenos' and 'vec' are data frames of 425x78 and 425x24128 respectively, all
> numeric variables. The 'phenos' has moderate number of NAs in some columnes.
>
> The problem dissapeared when trying to reduce the size of matrices (by 
> selection
> of rows and/or columns) and/or when simulating the data with random 
> generators.
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>   
I don't see anything to reproduce here, so how are we supposed to get a 
handle on the issue?

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Incorrect matrix of spearman correlations .... in 64-bit (PR#9570)

2007-03-16 Thread p . dalgaard
[EMAIL PROTECTED] wrote:
> Full_Name: Vladimir Obolonkin
> Version: tested in 2.0 to 2.4.1
> OS: linux, win, mac
> Submission from: (NULL) (202.14.96.194)
>
> {{ Subject shortened manually -- to pass anti-spam filters 
>
>Original-subject: Incorrect matrix of spearman correlations working \
>  large (24000 by 425 and 78 by 425 data frames)  in 64-bit Linux 
> machines;\
>   the same code gives correct results in 32-bits Win and Mac (PR#9568)
> }}
>
> cc_s<-cor(phenos,vec,method="spearman",use="pairwise.complete.obs")
>
> this is a line copied from real script producing different results in 64
> bit/Linux/R (wrong) and Mac&Win (correct)
>
> The script was implemented on 4 machines with Linux 64, Suse 9-10, in 5 
> variants
> of R -- versions from 2.3 to 2.4.1, compiled with few different settings of
> optimization and 2 versions of compilers. In all cases the results of spearman
> correlation were identical, but wrong.
>
> The same script was started up to 10 times in Win32 on Intel and Linux32 on 
> Mac
> with the Rs from 2.3 to 2.4.1 -- in this set of cases the results were 
> identical
> and correct.
>
> 'phenos' and 'vec' are data frames of 425x78 and 425x24128 respectively, all
> numeric variables. The 'phenos' has moderate number of NAs in some columnes.
>
> The problem dissapeared when trying to reduce the size of matrices (by 
> selection
> of rows and/or columns) and/or when simulating the data with random 
> generators.
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>   
I don't see anything to reproduce here, so how are we supposed to get a 
handle on the issue?

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread Benilton Carvalho
do you have a generic for 'export'?

On Mar 16, 2007, at 5:38 PM, cstrato wrote:

> Dear Benilton
>
> Thank you, now my package works.
>
> Do you have an explanation for my second problem:
>
> * Installing *source* package 'mytest' ...
> ** R
> ** save image
> Error in setMethod("export", "derivedClass", export.derivedClass) :
>no existing definition for function "export"
> Error: unable to load R code in package 'mytest'
> Execution halted
>
> What may be the reason for this error?
>
> Best regards
> Christian
>
>
> Benilton Carvalho wrote:
>> your namespace probably contains:
>>
>> useDynLib(testS4)
>>
>> but you don't have any compiled code...
>>
>> remove that line and everything will be fine.
>>
>> btw, if you're playing with S4, you must import 'methods'
>>
>> b
>>
>> On Mar 16, 2007, at 4:55 PM, cstrato wrote:
>>
>>> Dear all,
>>>
>>> Currently, I am trying to create a test package "testS4" using S4  
>>> classes,
>>> which I am attaching.
>>>
>>> Running R CMD check gives the following error:
>>>
>>> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD check  
>>> testS4_0.1.1.tar.gz
>>> * checking for working latex ...sh: line 1: latex: command not found
>>> NO
>>> * using log directory '/Volumes/CoreData/CRAN/testS4.Rcheck'
>>> * using R version 2.5.0 Under development (unstable) (2007-02-26  
>>> r40806)
>>> * checking for file 'testS4/DESCRIPTION' ... OK
>>> * this is package 'testS4' version '0.1.1'
>>> * checking package dependencies ... OK
>>> * checking if this is a source package ... OK
>>> * checking whether package 'testS4' can be installed ... OK
>>> * checking package directory ... OK
>>> * checking for portable file names ... OK
>>> * checking for sufficient/correct file permissions ... OK
>>> * checking DESCRIPTION meta-information ... OK
>>> * checking top-level files ... OK
>>> * checking index information ... OK
>>> * checking package subdirectories ... OK
>>> * checking R files for non-ASCII characters ... OK
>>> * checking R files for syntax errors ... OK
>>> * checking whether the package can be loaded ... ERROR
>>> Error in library.dynam(lib, package, package.lib) :
>>>shared library 'testS4' not found
>>> Error: package/namespace load failed for 'testS4'
>>> Execution halted
>>>
>>> Can someone explain what this error means?
>>> What is meant with "shared library"?
>>>
>>> For another test package I get the following error
>>> coeurebooks-computer:/Volumes/CoreData/CRAN cs$ R CMD INSTALL -l  
>>> ~/Library/R/library mytest_0.3.2.tar.gz
>>> * Installing *source* package 'mytest' ...
>>> ** R
>>> ** save image
>>> Error in setMethod("export", "derivedClass", export.derivedClass) :
>>>no existing definition for function "export"
>>> Error: unable to load R code in package 'mytest'
>>> Execution halted
>>>
>>> This error is even more strange since I cannot reproduce it in  
>>> the attached package.
>>> What may be the reason for this error?
>>>
>>> Thank you in advance.
>>> Best regards
>>> Christian
>>> _._._._._._._._._._._._._._._._
>>> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
>>> V.i.e.n.n.a   A.u.s.t.r.i.a
>>> _._._._._._._._._._._._._._._._
>>>
>>> 
>>> __
>>> R-devel@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Inherited S4 methods

2007-03-16 Thread Seth Falcon
cstrato <[EMAIL PROTECTED]> writes:

> Dear Seth
>
> Thank you, maybe I still do not understand S4 methods.
>
> I thought that the purpose of function "callNextMethod()" is to allow
> some kind of inheritance. In the Bioconuductor packages which are
> using S4, it is only used for method("initialize") but I thought, that
> it can be used with every method "mymethod()", is this correct?

Yes, callNextMethod can be used in any method definition.  When you
call a generic function, the system creates a list of all methods for
that generic that are applicable and orders them so that the most
specific method comes first.  When you call callNextMethod, you enter
the next most specific method.

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Inherited S4 methods

2007-03-16 Thread cstrato
Dear Seth

Thank you, I will further explain this feature.

Best regards
Christian

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato
Dear Benilton

Yes, but the error disappears only when I define it twice.

For my package I create three files:

1. MyClasses.R:
Here I define the classes only using
setClass("baseClass")
setClass("derivedClass")

2. methods.baseClass.R
Here I define the methods for baseClass
setGeneric("export", function(object,...) standardGeneric("export"))
setMethod("export", "baseClass", export.baseClass);

3. methods.derivedClass.R
Here I define the methods for derivedClass
setGeneric("export", function(object,...) standardGeneric("export"))
setMethod("export", "derivedClass", export.derivedClass);

As you see, I need to define setGeneric twice, otherwise I get the error.
It is not clear to me, why this is the case?

I know, that BioBase has a file AllGeneric.R, but I would like to define
the generics in the respective methods files.

Best regards
Christian

Benilton Carvalho wrote:
> do you have a generic for 'export'?
>
> On Mar 16, 2007, at 5:38 PM, cstrato wrote:
>
>> Dear Benilton
>>
>> Thank you, now my package works.
>>
>> Do you have an explanation for my second problem:
>>
>> * Installing *source* package 'mytest' ...
>> ** R
>> ** save image
>> Error in setMethod("export", "derivedClass", export.derivedClass) :
>>no existing definition for function "export"
>> Error: unable to load R code in package 'mytest'
>> Execution halted
>>
>> What may be the reason for this error?
>>
>> Best regards
>> Christian
>>
>>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread Benilton Carvalho
Well, my understanding is that if you "need" to define it (the  
generic) twice you're doing something wrong.

Do you have a collate field in your description file? IMHO, the  
"AllGeneric.R"/"AllClasses.R" approach is the way to go... keeping  
your code organized is always a good thing, right?

b

On Mar 16, 2007, at 6:35 PM, cstrato wrote:

> Dear Benilton
>
> Yes, but the error disappears only when I define it twice.
>
> For my package I create three files:
>
> 1. MyClasses.R:
> Here I define the classes only using
> setClass("baseClass")
> setClass("derivedClass")
>
> 2. methods.baseClass.R
> Here I define the methods for baseClass
> setGeneric("export", function(object,...) standardGeneric("export"))
> setMethod("export", "baseClass", export.baseClass);
>
> 3. methods.derivedClass.R
> Here I define the methods for derivedClass
> setGeneric("export", function(object,...) standardGeneric("export"))
> setMethod("export", "derivedClass", export.derivedClass);
>
> As you see, I need to define setGeneric twice, otherwise I get the  
> error.
> It is not clear to me, why this is the case?
>
> I know, that BioBase has a file AllGeneric.R, but I would like to  
> define
> the generics in the respective methods files.
>
> Best regards
> Christian
>
> Benilton Carvalho wrote:
>> do you have a generic for 'export'?
>>
>> On Mar 16, 2007, at 5:38 PM, cstrato wrote:
>>
>>> Dear Benilton
>>>
>>> Thank you, now my package works.
>>>
>>> Do you have an explanation for my second problem:
>>>
>>> * Installing *source* package 'mytest' ...
>>> ** R
>>> ** save image
>>> Error in setMethod("export", "derivedClass", export.derivedClass) :
>>>no existing definition for function "export"
>>> Error: unable to load R code in package 'mytest'
>>> Execution halted
>>>
>>> What may be the reason for this error?
>>>
>>> Best regards
>>> Christian
>>>
>>>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato
I agree, but I hope that "AllGeneric.R" is not the only possibility.
BTW, what is a collate field?

Best regards
Christian

Benilton Carvalho wrote:
> Well, my understanding is that if you "need" to define it (the 
> generic) twice you're doing something wrong.
>
> Do you have a collate field in your description file? IMHO, the 
> "AllGeneric.R"/"AllClasses.R" approach is the way to go... keeping 
> your code organized is always a good thing, right?
>
> b
>
> On Mar 16, 2007, at 6:35 PM, cstrato wrote:
>
>> Dear Benilton
>>
>> Yes, but the error disappears only when I define it twice.
>>
>> For my package I create three files:
>>
>> 1. MyClasses.R:
>> Here I define the classes only using
>> setClass("baseClass")
>> setClass("derivedClass")
>>
>> 2. methods.baseClass.R
>> Here I define the methods for baseClass
>> setGeneric("export", function(object,...) standardGeneric("export"))
>> setMethod("export", "baseClass", export.baseClass);
>>
>> 3. methods.derivedClass.R
>> Here I define the methods for derivedClass
>> setGeneric("export", function(object,...) standardGeneric("export"))
>> setMethod("export", "derivedClass", export.derivedClass);
>>
>> As you see, I need to define setGeneric twice, otherwise I get the 
>> error.
>> It is not clear to me, why this is the case?
>>
>> I know, that BioBase has a file AllGeneric.R, but I would like to define
>> the generics in the respective methods files.
>>
>> Best regards
>> Christian
>>
>> Benilton Carvalho wrote:
>>> do you have a generic for 'export'?
>>>
>>> On Mar 16, 2007, at 5:38 PM, cstrato wrote:
>>>
 Dear Benilton

 Thank you, now my package works.

 Do you have an explanation for my second problem:

 * Installing *source* package 'mytest' ...
 ** R
 ** save image
 Error in setMethod("export", "derivedClass", export.derivedClass) :
no existing definition for function "export"
 Error: unable to load R code in package 'mytest'
 Execution halted

 What may be the reason for this error?

 Best regards
 Christian


>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread Benilton Carvalho
The Collate field gives the order that the files are going to be  
concatenated. If they're concatenated using the "wrong" order, your  
installation might fail (for example, the generic is defined after  
the method).

A recommended source is the  "Writing R Extensions"

http://cran.r-project.org/doc/manuals/R-exts.html

Session 1.1.1 - The Description File (Writing R Extensions)

says exactly what you shohuld know about the Collate field (and not  
only that).

b

On Mar 16, 2007, at 7:01 PM, cstrato wrote:

> I agree, but I hope that "AllGeneric.R" is not the only possibility.
> BTW, what is a collate field?
>
> Best regards
> Christian
>
> Benilton Carvalho wrote:
>> Well, my understanding is that if you "need" to define it (the  
>> generic) twice you're doing something wrong.
>>
>> Do you have a collate field in your description file? IMHO, the  
>> "AllGeneric.R"/"AllClasses.R" approach is the way to go... keeping  
>> your code organized is always a good thing, right?
>>
>> b
>>
>> On Mar 16, 2007, at 6:35 PM, cstrato wrote:
>>
>>> Dear Benilton
>>>
>>> Yes, but the error disappears only when I define it twice.
>>>
>>> For my package I create three files:
>>>
>>> 1. MyClasses.R:
>>> Here I define the classes only using
>>> setClass("baseClass")
>>> setClass("derivedClass")
>>>
>>> 2. methods.baseClass.R
>>> Here I define the methods for baseClass
>>> setGeneric("export", function(object,...) standardGeneric("export"))
>>> setMethod("export", "baseClass", export.baseClass);
>>>
>>> 3. methods.derivedClass.R
>>> Here I define the methods for derivedClass
>>> setGeneric("export", function(object,...) standardGeneric("export"))
>>> setMethod("export", "derivedClass", export.derivedClass);
>>>
>>> As you see, I need to define setGeneric twice, otherwise I get  
>>> the error.
>>> It is not clear to me, why this is the case?
>>>
>>> I know, that BioBase has a file AllGeneric.R, but I would like to  
>>> define
>>> the generics in the respective methods files.
>>>
>>> Best regards
>>> Christian
>>>
>>> Benilton Carvalho wrote:
 do you have a generic for 'export'?

 On Mar 16, 2007, at 5:38 PM, cstrato wrote:

> Dear Benilton
>
> Thank you, now my package works.
>
> Do you have an explanation for my second problem:
>
> * Installing *source* package 'mytest' ...
> ** R
> ** save image
> Error in setMethod("export", "derivedClass",  
> export.derivedClass) :
>no existing definition for function "export"
> Error: unable to load R code in package 'mytest'
> Execution halted
>
> What may be the reason for this error?
>
> Best regards
> Christian
>
>
>>
>>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato
Thank you, I have already read the R-exts manual, but the collate field 
is optional.
Do you know a package which uses the Collate field so that I can study it?

Best regards
Christian

Benilton Carvalho wrote:
> The Collate field gives the order that the files are going to be 
> concatenated. If they're concatenated using the "wrong" order, your 
> installation might fail (for example, the generic is defined after the 
> method).
>
> A recommended source is the  "Writing R Extensions"
>
> http://cran.r-project.org/doc/manuals/R-exts.html
>
> Session 1.1.1 - The Description File (Writing R Extensions)
>
> says exactly what you shohuld know about the Collate field (and not 
> only that).
>
> b
>
> On Mar 16, 2007, at 7:01 PM, cstrato wrote:

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread Benilton Carvalho
Biobase itself does.
b

On Mar 16, 2007, at 7:43 PM, cstrato wrote:

> Thank you, I have already read the R-exts manual, but the collate  
> field is optional.
> Do you know a package which uses the Collate field so that I can  
> study it?
>
> Best regards
> Christian
>
> Benilton Carvalho wrote:
>> The Collate field gives the order that the files are going to be  
>> concatenated. If they're concatenated using the "wrong" order,  
>> your installation might fail (for example, the generic is defined  
>> after the method).
>>
>> A recommended source is the  "Writing R Extensions"
>>
>> http://cran.r-project.org/doc/manuals/R-exts.html
>>
>> Session 1.1.1 - The Description File (Writing R Extensions)
>>
>> says exactly what you shohuld know about the Collate field (and  
>> not only that).
>>
>> b
>>
>> On Mar 16, 2007, at 7:01 PM, cstrato wrote:

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] R 2.5.0 devel try issue in conjuntion with S4 method dispatch

2007-03-16 Thread Seth Falcon
"Matthias Burger" <[EMAIL PROTECTED]> writes:
> Well, I understand I should have spent more time trimming my example
> to the minimal required code. Again this piece was copied & reduced.

No need to have done anything differently.  I commented on the code
in hopes that it might be helpful for others learning S4 stuff -- so I
think the discussion is useful even if it isn't your real code :-)

> The actual package uses a namespace which only exports the method but not
> the function.
> Using the .className extension scheme I can still get at the actual
> code at the R prompt via ':::'  which I find just handy.

If you switched to _className, then there would be no S3 confusion.
There are performance implications in doing things this way, but I
agree it is convenient.

Cheers,

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Problems with package containing S4 classes

2007-03-16 Thread cstrato
I must have missed this, thank you.

Good night
Christian

Benilton Carvalho wrote:
> Biobase itself does.
> b
>
> On Mar 16, 2007, at 7:43 PM, cstrato wrote:
>
>> Thank you, I have already read the R-exts manual, but the collate 
>> field is optional.
>> Do you know a package which uses the Collate field so that I can 
>> study it?
>>
>> Best regards
>> Christian
>>
>> Benilton Carvalho wrote:
>>> The Collate field gives the order that the files are going to be 
>>> concatenated. If they're concatenated using the "wrong" order, your 
>>> installation might fail (for example, the generic is defined after 
>>> the method).
>>>
>>> A recommended source is the  "Writing R Extensions"
>>>
>>> http://cran.r-project.org/doc/manuals/R-exts.html
>>>
>>> Session 1.1.1 - The Description File (Writing R Extensions)
>>>
>>> says exactly what you shohuld know about the Collate field (and not 
>>> only that).
>>>
>>> b
>>>
>>> On Mar 16, 2007, at 7:01 PM, cstrato wrote:
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel