Re: [Rd] Class not found when search in .onLoad

2011-06-27 Thread Renaud Gaujoux


On 24/06/2011 22:04, John Chambers wrote:


Strictly speaking, that is not meaningful.  A class (like any R 
object) is uniquely referenced by a name *and an environment*.  The 
name of a package can be used to construct the environment, but your 
"character slot" won't identify a class reliably unless the character 
string has a "package" attribute.


Look at class(x), for example, from an object from one of these 
classes.  It will have a "package" attribute identifying the package.
The character string with the package attribute is what you should be 
storing in the slot (or else store the class definition---takes more 
space but is slightly more efficient).




Thank you for this clarification, I will make my factory method for the 
relevant class add the package attribute to the slot.
Storing the class would require recreating the object if the user makes 
changes in the class definition. These objects are meant to be used when 
developing new algorithms. In this context one expects the user to do 
multiple tries and modifications, and I want to ease the process, by 
using dynamic links to classes (a character slot) rather than static 
links (result of getClass).


However, this does not explain why .onLoad does not find the class while 
.onAttach finds it, does it?
Is .onLoad evaluated outside the namespace environment, while .onAttach 
is evaluated within the namespace?


Thank you.
Renaud



###
UNIVERSITY OF CAPE TOWN 


This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}

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


Re: [Rd] Class not found when search in .onLoad

2011-06-27 Thread Simon Urbanek
On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote:

> 
> On 24/06/2011 22:04, John Chambers wrote:
>> 
>> Strictly speaking, that is not meaningful.  A class (like any R object) is 
>> uniquely referenced by a name *and an environment*.  The name of a package 
>> can be used to construct the environment, but your "character slot" won't 
>> identify a class reliably unless the character string has a "package" 
>> attribute.
>> 
>> Look at class(x), for example, from an object from one of these classes.  It 
>> will have a "package" attribute identifying the package.
>> The character string with the package attribute is what you should be 
>> storing in the slot (or else store the class definition---takes more space 
>> but is slightly more efficient).
>> 
> 
> Thank you for this clarification, I will make my factory method for the 
> relevant class add the package attribute to the slot.
> Storing the class would require recreating the object if the user makes 
> changes in the class definition. These objects are meant to be used when 
> developing new algorithms. In this context one expects the user to do 
> multiple tries and modifications, and I want to ease the process, by using 
> dynamic links to classes (a character slot) rather than static links (result 
> of getClass).
> 
> However, this does not explain why .onLoad does not find the class while 
> .onAttach finds it, does it?
> Is .onLoad evaluated outside the namespace environment, while .onAttach is 
> evaluated within the namespace?
> 

Look at the default of where - it is the top environment, not the evaluated 
one, and in .onLoad the namespace is not attached yet while it is in .onAttach.

Cheers,
S

Possibly @John: it's a bit puzzling that isClass has a default for where yet it 
is entirely ignored as getClassDef is called without where. If anyone changes 
the default in getDeffClass() then isClass signature will be misleading - is 
there a practical reason for this construct? Thanks, S.
__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Class not found when search in .onLoad

2011-06-27 Thread Renaud Gaujoux


On 27/06/2011 14:27, Simon Urbanek wrote:

On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote:


On 24/06/2011 22:04, John Chambers wrote:

Strictly speaking, that is not meaningful.  A class (like any R object) is uniquely referenced by a 
name *and an environment*.  The name of a package can be used to construct the environment, but 
your "character slot" won't identify a class reliably unless the character string has a 
"package" attribute.

Look at class(x), for example, from an object from one of these classes.  It will have a 
"package" attribute identifying the package.
The character string with the package attribute is what you should be storing 
in the slot (or else store the class definition---takes more space but is 
slightly more efficient).


Thank you for this clarification, I will make my factory method for the 
relevant class add the package attribute to the slot.
Storing the class would require recreating the object if the user makes changes 
in the class definition. These objects are meant to be used when developing new 
algorithms. In this context one expects the user to do multiple tries and 
modifications, and I want to ease the process, by using dynamic links to 
classes (a character slot) rather than static links (result of getClass).

However, this does not explain why .onLoad does not find the class while 
.onAttach finds it, does it?
Is .onLoad evaluated outside the namespace environment, while .onAttach is 
evaluated within the namespace?


Look at the default of where - it is the top environment, not the evaluated 
one, and in .onLoad the namespace is not attached yet while it is in .onAttach.
Ok, but .onLoad is defined in the source of the package (i.e. within the 
package's namespace, am I correct?).
So from what I get from the docs (copy/pasted below), isn't the 
top-environment supposed to be the package's namepsace, even if the 
package is not yet attached, and its namepace not yet in the search path?


from ?isClass
" where: The environment in which to modify or remove the definition.
Defaults to the top-level environment of the calling function
(the global environment for ordinary computations, but the
environment or name space of a package in the source for a
package).

When searching for class definitions, ‘where’ defines where
to do the search, and the default is to search from the
top-level environment or name space of the caller to this
function."

from ?topenv
"‘topenv’ returns the first top level environment found when
searching ‘envir’ and its enclosing environments. An environment
is considered top level if it is the internal environment of a
name space, a package environment in the search path, or
‘.GlobalEnv’."


Cheers,
S

Possibly @John: it's a bit puzzling that isClass has a default for where yet it 
is entirely ignored as getClassDef is called without where. If anyone changes 
the default in getDeffClass() then isClass signature will be misleading - is 
there a practical reason for this construct? Thanks, S.




###
UNIVERSITY OF CAPE TOWN 


This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}

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


Re: [Rd] Class not found when search in .onLoad

2011-06-27 Thread Simon Urbanek

On Jun 27, 2011, at 8:43 AM, Renaud Gaujoux wrote:

> 
> On 27/06/2011 14:27, Simon Urbanek wrote:
>> On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote:
>> 
>>> On 24/06/2011 22:04, John Chambers wrote:
 Strictly speaking, that is not meaningful.  A class (like any R object) is 
 uniquely referenced by a name *and an environment*.  The name of a package 
 can be used to construct the environment, but your "character slot" won't 
 identify a class reliably unless the character string has a "package" 
 attribute.
 
 Look at class(x), for example, from an object from one of these classes.  
 It will have a "package" attribute identifying the package.
 The character string with the package attribute is what you should be 
 storing in the slot (or else store the class definition---takes more space 
 but is slightly more efficient).
 
>>> Thank you for this clarification, I will make my factory method for the 
>>> relevant class add the package attribute to the slot.
>>> Storing the class would require recreating the object if the user makes 
>>> changes in the class definition. These objects are meant to be used when 
>>> developing new algorithms. In this context one expects the user to do 
>>> multiple tries and modifications, and I want to ease the process, by using 
>>> dynamic links to classes (a character slot) rather than static links 
>>> (result of getClass).
>>> 
>>> However, this does not explain why .onLoad does not find the class while 
>>> .onAttach finds it, does it?
>>> Is .onLoad evaluated outside the namespace environment, while .onAttach is 
>>> evaluated within the namespace?
>>> 
>> Look at the default of where - it is the top environment, not the evaluated 
>> one, and in .onLoad the namespace is not attached yet while it is in 
>> .onAttach.
> Ok, but .onLoad is defined in the source of the package (i.e. within the 
> package's namespace, am I correct?).
> So from what I get from the docs (copy/pasted below), isn't the 
> top-environment supposed to be the package's namepsace, even if the package 
> is not yet attached, and its namepace not yet in the search path?
> 

Not in this case, because where is the methods namespace (see the bottom of my 
last e-mail - where is not evaluated in environment of your package but in 
methods due to the default being removed by isClass). I would say this is a bug 
- changing isClass to the trivial

isClass <- function(Class, formal=TRUE, where = topenv(parent.frame())) 
!is.null(getClassDef(Class, where))

has the desired effect.

Cheers,
Simon


> from ?isClass
> " where: The environment in which to modify or remove the definition.
> Defaults to the top-level environment of the calling function
> (the global environment for ordinary computations, but the
> environment or name space of a package in the source for a
> package).
> 
> When searching for class definitions, ‘where’ defines where
> to do the search, and the default is to search from the
> top-level environment or name space of the caller to this
> function."
> 
> from ?topenv
> "‘topenv’ returns the first top level environment found when
> searching ‘envir’ and its enclosing environments. An environment
> is considered top level if it is the internal environment of a
> name space, a package environment in the search path, or
> ‘.GlobalEnv’."
> 
>> Cheers,
>> S
>> 
>> Possibly @John: it's a bit puzzling that isClass has a default for where yet 
>> it is entirely ignored as getClassDef is called without where. If anyone 
>> changes the default in getDeffClass() then isClass signature will be 
>> misleading - is there a practical reason for this construct? Thanks, S.
> 
> 
> ###
> UNIVERSITY OF CAPE TOWN 
> This e-mail is subject to the UCT ICT policies and e-mail disclaimer 
> published on our website at 
> http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from +27 
> 21 650 9111. This e-mail is intended only for the person(s) to whom it is 
> addressed. If the e-mail has reached you in error, please notify the author. 
> If you are not the intended recipient of the e-mail you may not use, 
> disclose, copy, redirect or print the content. If this e-mail is not related 
> to the business of UCT it is sent by the sender in the sender's individual 
> capacity.
> 
> ###
> 
> 

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


Re: [Rd] Class not found when search in .onLoad

2011-06-27 Thread Renaud Gaujoux

All is clear now.
Thank you for this clarification.

Cheers,
Renaud

On 27/06/2011 15:38, Simon Urbanek wrote:

On Jun 27, 2011, at 8:43 AM, Renaud Gaujoux wrote:


On 27/06/2011 14:27, Simon Urbanek wrote:

On Jun 27, 2011, at 3:17 AM, Renaud Gaujoux wrote:


On 24/06/2011 22:04, John Chambers wrote:

Strictly speaking, that is not meaningful.  A class (like any R object) is uniquely referenced by a 
name *and an environment*.  The name of a package can be used to construct the environment, but 
your "character slot" won't identify a class reliably unless the character string has a 
"package" attribute.

Look at class(x), for example, from an object from one of these classes.  It will have a 
"package" attribute identifying the package.
The character string with the package attribute is what you should be storing 
in the slot (or else store the class definition---takes more space but is 
slightly more efficient).


Thank you for this clarification, I will make my factory method for the 
relevant class add the package attribute to the slot.
Storing the class would require recreating the object if the user makes changes 
in the class definition. These objects are meant to be used when developing new 
algorithms. In this context one expects the user to do multiple tries and 
modifications, and I want to ease the process, by using dynamic links to 
classes (a character slot) rather than static links (result of getClass).

However, this does not explain why .onLoad does not find the class while 
.onAttach finds it, does it?
Is .onLoad evaluated outside the namespace environment, while .onAttach is 
evaluated within the namespace?


Look at the default of where - it is the top environment, not the evaluated 
one, and in .onLoad the namespace is not attached yet while it is in .onAttach.

Ok, but .onLoad is defined in the source of the package (i.e. within the 
package's namespace, am I correct?).
So from what I get from the docs (copy/pasted below), isn't the top-environment 
supposed to be the package's namepsace, even if the package is not yet 
attached, and its namepace not yet in the search path?


Not in this case, because where is the methods namespace (see the bottom of my 
last e-mail - where is not evaluated in environment of your package but in 
methods due to the default being removed by isClass). I would say this is a bug 
- changing isClass to the trivial

isClass<- function(Class, formal=TRUE, where = topenv(parent.frame())) 
!is.null(getClassDef(Class, where))

has the desired effect.

Cheers,
Simon



from ?isClass
" where: The environment in which to modify or remove the definition.
Defaults to the top-level environment of the calling function
(the global environment for ordinary computations, but the
environment or name space of a package in the source for a
package).

When searching for class definitions, ‘where’ defines where
to do the search, and the default is to search from the
top-level environment or name space of the caller to this
function."

from ?topenv
"‘topenv’ returns the first top level environment found when
searching ‘envir’ and its enclosing environments. An environment
is considered top level if it is the internal environment of a
name space, a package environment in the search path, or
‘.GlobalEnv’."


Cheers,
S

Possibly @John: it's a bit puzzling that isClass has a default for where yet it 
is entirely ignored as getClassDef is called without where. If anyone changes 
the default in getDeffClass() then isClass signature will be misleading - is 
there a practical reason for this construct? Thanks, S.


###
UNIVERSITY OF CAPE TOWN
This e-mail is subject to the UCT ICT policies and e-mail disclaimer published 
on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or 
obtainable from +27 21 650 9111. This e-mail is intended only for the person(s) 
to whom it is addressed. If the e-mail has reached you in error, please notify 
the author. If you are not the intended recipient of the e-mail you may not 
use, disclose, copy, redirect or print the content. If this e-mail is not 
related to the business of UCT it is sent by the sender in the sender's 
individual capacity.

###






###
UNIVERSITY OF CAPE TOWN 


This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:5}}

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


Re: [Rd] Is there an implementation of loess with more than 3 parametric ...

2011-06-27 Thread Ben Bolker
Dr. D. P. Kreil (Boku  boku.ac.at> writes:

> 
> Dear John,
> 
> > I suggest that you look at the abilities of the mgcv package.
> > There are notes of mine at
> >
> > http://www.maths.anu.edu.au/%7Ejohnm/r-book/xtras/autosmooth.pdf
> >
> > that may help you get started.
> 
> Thank you very much for the suggestion and the link to your write-up,
> it was indeed very helpful!
> 
> I have experimented with this library for a while now and am really
> happy about its flexibility. For my immediate applied problem, I will
> now go with a gam fit ("z~te(x,y)+fa-1").
> 
> I note, however, that this is much, much slower than loess, and is
> thus limited to smaller numbers of data points. (I could not fit the
> full model to 50,000 data points in a reasonable time.)
> I am therefore wondering if you knew of a way of also fixing the
> implementation of loess in R?
> 
> >From the error message (recompile with larger d2MAX) it seems that the
> underlying Fortran library was perfectly happy to fit a larger number
> of parametric variables. So is there a way one could remove the
> restriction to 4 parameters in the R interface/compilation? I have not
> found an obvious place where d2MAX is defined or configured, I suspect
> it might be hard-coded...
> 

  If you go looking for d2MAX in the R code (i.e. download the entire
source or get a copy of the SVN tree) you will proceed as follows:

 find . -name "*.c" -exec grep -l d2MAX {} \;


takes you to ./src/library/stats/src/loessc.c

Looking therein finds:

 case 105:MSG("k>d2MAX in ehg136.  Need to recompile with increased 
dimensions.")

  grep 105 *.f finds loessf.f

within which we find two lines (1240 and 1361)

  if(k .gt. 15)   call ehg182(105)

Searching for "15" then finds a *lot* of places where "15" is 
hardcoded in the file.

 To modify the file you could either blindly change all the hard-coded
"15" dimensions to something larger and hope that it worked (i.e., use
a good test suite to make sure you didn't screw something up) or dig
through the code and understand it in detail to know what should
be changed ...

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


[Rd] R CMD check --force-multiarch does not install all the archs for testing

2011-06-27 Thread Hervé Pagès

Hi,

Why isn't 'R CMD check --force-multiarch' installing the package
for all the architectures that are going to be checked?
For some packages, it only installs for the default arch ('i386').
Then testing the package for 'x64' fails.

For example,

Output of R CMD check --force-multiarch fabia_1.5.0.tar.gz:
---
* using log directory 'D:/biocbld/bbs-2.9-bioc/meat/fabia.Rcheck'
* using R version 2.14.0 Under development (unstable) (2011-05-30 r56020)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* using option '--no-vignettes'
* checking for file 'fabia/DESCRIPTION' ... OK
* this is package 'fabia' version '1.5.0'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking whether package 'fabia' can be installed ... OK
* checking installed package size ... OK
* checking package directory ... OK
* checking for portable file names ... 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
* loading checks for arch 'i386'
** checking whether the package can be loaded ... OK
** checking whether the package can be loaded with stated dependencies 
... OK

** checking whether the package can be unloaded cleanly ... OK
** checking whether the name space can be loaded with stated 
dependencies ... OK

** checking whether the name space can be unloaded cleanly ... OK
* loading checks for arch 'x64'
** checking whether the package can be loaded ...Warning: running 
command '"D:/biocbld/bbs-2.9-bioc/R/bin/x64/Rterm.exe" 
R_ENVIRON_USER='no_such_file' --no-site-file --no-init-file --no-save 
--no-restore --slave -f 
D:\biocbld\bbs-2.9-bioc\tmpdir\RtmpO65p5H\Rin57456988' had status 1

 ERROR
Error: package 'fabia' is not installed for 'arch=x64'
Execution halted

It looks like this package has a loading problem: see the messages for
details.

Content of fabia.Rcheck\00install.out:
--

* installing *source* package 'fabia' ...
Building libRcpp.a in RcppSrc...
rm -f Rcpp.o  libRcpp.a
g++  -c Rcpp.cpp -o Rcpp.o -I"D:/biocbld/BBS-2˜1.9-B/R/include" 
-I"D:/biocbld/BBS-2˜1.9-B/R/src/include"  -Wall -O2

ar r libRcpp.a Rcpp.o
C:\Rtools213\MinGW\bin\ar.exe: creating libRcpp.a
ranlib  libRcpp.a
rm -f Rcpp.o
rm -f Rcpp.o
** libs
  running src/Makefile.win ...
rm -f fabia.o fabia.dll *.a *.o *.so *.dll
g++  -c fabiac.cpp -o fabia.o -I../RcppSrc 
-I"D:/biocbld/BBS-2˜1.9-B/R/include" -Wall -O2
g++  -shared -s -static-libgcc fabia.o -L../RcppSrc -lRcpp 
-L"D:/biocbld/BBS-2˜1.9-B/R/bin/i386"  -lR  -o fabia.dll

rm -f fabia.o *.a *.o *.so
installing to D:/biocbld/bbs-2.9-bioc/meat/fabia.Rcheck/fabia/libs/i386
** R
** demo
** inst
** preparing package for lazy loading
Creating a generic function for "plot" from package "graphics" in 
package "fabia"

** help
*** installing help indices
** building package indices ...
*** tangling vignette sources ...
   'fabia.Rnw'
** testing if installed package can be loaded

* DONE (fabia)

The source tarball for this package is available here:
  http://bioconductor.org/packages/2.9/bioc/html/fabia.html

What command should be used to perform a multiarch check of this
package?

This is on a 64-bit Windows Server 2008 R2 Enterprise machine using a
recent combined Windows 32/64 bit binary of R-devel from CRAN.

Thanks!
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpa...@fhcrc.org
Phone:  (206) 667-5791
Fax:(206) 667-1319

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