[Rd] cannot connect to an FTP server with long HELLO message

2010-10-22 Thread Hervé Pagès

Hi,

Trying to access files on the ftp server at ftp.ncbi.nih.gov
will either give a time out or sometimes even a segfault on Linux.
The 2 following methods give the same results:

  f - 
url(ftp://ftp.ncbi.nih.gov/pub/geo/DATA/SOFT/GDS/GDS10.soft.gz;, open=r)



download.file(ftp://ftp.ncbi.nih.gov/pub/geo/DATA/SOFT/GDS/GDS10.soft.gz;, 
destfile=tempfile())


I've tried one or the other method with all release versions = 2.8
and with current R devel and they always fail to connect to this
FTP server.

What's particular about this FTP server is that it sends a long HELLO
message before it finally sends the 220 control code.
Using the Unix ftp client:

-
hpa...@latitude:~$ ftp ftp.ncbi.nih.gov
Connected to ftp.ncbi.nih.gov.
220-
 Warning Notice!

 This is a U.S. Government computer system, which may be accessed and used
 only for authorized Government business by authorized personnel.
 Unauthorized access or use of this computer system may subject 
violators to

 criminal, civil, and/or administrative action.

 All information on this computer system may be intercepted, recorded, 
read,
 copied, and disclosed by and to authorized personnel for official 
purposes,
 including criminal investigations. Such information includes sensitive 
data

 encrypted to comply with confidentiality and privacy requirements. Access
 or use of this computer system by any person, whether authorized or
 unauthorized, constitutes consent to these terms. There is no right of
 privacy in this system.
 ---
 Welcome to the NCBI ftp server! The official anonymous access URL is 
ftp://ftp.ncbi.nih.gov


 Public data may be downloaded by logging in as anonymous using your 
E-mail address as a password.


 Please see ftp://ftp.ncbi.nih.gov/README.ftp for hints on large file 
transfers

220 FTP Server ready.
-

This seems to cause problems to the nanoftp module
(src/modules/internet/nanoftp.c) used by url() and download.file()
as it doesn't seem to be able to catch the 220 control code.

I'm not familiar with the nanoftp module, or with socket programming in
general, or with RFC 959 (FTP protocal), so I'm not really in a position
to say what's going wrong exactly in the module but it seems that
increasing the value of FTP_BUF_SIZE (size of the buffer for data
received from the control connection) fixes the problem.
Currently this is:

#define FTP_BUF_SIZE1024

but, interestingly, *any* value  1024 seems to fix the problem (even
though the long HELLO message above is 1091 bytes).

Any idea what's going on?

Thanks,
H.

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
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


[Rd] Linking to lapack

2010-10-22 Thread Nick Sabbe
Hello all.

I'm developing a package for R holding a Gibbs sampler, which tends to have
better performance when written in C than in R.
During each iteration in the Gibbs sampler, I need the inverse of a
symmetric matrix.
For this, I wish to use lapack, as is concisely suggested in Writing R
extensions, since this will have better performance than I could ever write
myself.

After some twiddling I have got my code to compile by including
R_ext/Lapack.h and using F77_CALL(dpotrf), but unfortunately, I don't
get this to link properly.
I get this message:  testc.o:testc.c:(.text+0x255): undefined reference to
`dpotrf_' which seems logical to me as far as my understanding of C
reaches, but I don't know how to resolve it. I'm quite sure I need some
extra parameters in my makefile, but as I come from a world where all these
complexities are happily abstracted away for me by an IDE, I have no actual
clue on how to surmount this.

However: when I'm done with all my code, I wish to build a package for
publication on CRAN, so I want to be sure that not only I can build it on my
system, but it will also work well when distributed to other computers (if I
understand the package process well, source files are compiled and linked
during installation of the package), so I would also like to know how to do
this.

It should not be relevant, but either way: I'm doing all this on a Windows 7
machine, though the package will probably be used on Linux-based servers
eventually.

Finally: I have found no comprehensive list of the functions available to an
R package developer, nor, strangely, questions about that. Does such a thing
exist, or are we up to hoping we find what we are looking for in the header
files? If it does not exist already, I would surely be willing to work on
it.

Thanks for any input.

Nick Sabbe
--
ping: nick.sa...@ugent.be
link: http://biomath.ugent.be
wink: A1.056, Coupure Links 653, 9000 Gent
ring: 09/264.59.36

-- Do Not Disapprove

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


Re: [Rd] Linking to lapack

2010-10-22 Thread Douglas Bates
On Fri, Oct 22, 2010 at 4:30 AM, Nick Sabbe nick.sa...@ugent.be wrote:
 Hello all.

 I'm developing a package for R holding a Gibbs sampler, which tends to have
 better performance when written in C than in R.
 During each iteration in the Gibbs sampler, I need the inverse of a
 symmetric matrix.

You may want to check that.  The first rule of numerical linear
algebra is that you hardly ever need to invert a matrix.  If you need
to solve a linear system, you use a factorization, as below and then
use one of the solvers based on that factorization.  If the matrix is
small calculating the inverse is not a big problem.  If it is large
and you do so within each iteration of your sampler then you are
probably wasting time.

 For this, I wish to use lapack, as is concisely suggested in Writing R
 extensions, since this will have better performance than I could ever write
 myself.

 After some twiddling I have got my code to compile by including
 R_ext/Lapack.h and using F77_CALL(dpotrf), but unfortunately, I don't
 get this to link properly.
 I get this message:  testc.o:testc.c:(.text+0x255): undefined reference to
 `dpotrf_' which seems logical to me as far as my understanding of C
 reaches, but I don't know how to resolve it. I'm quite sure I need some
 extra parameters in my makefile, but as I come from a world where all these
 complexities are happily abstracted away for me by an IDE, I have no actual
 clue on how to surmount this.

Go back to section 1.2.1 of Writing R Extensions that deals with
Using Makevars.

 However: when I'm done with all my code, I wish to build a package for
 publication on CRAN, so I want to be sure that not only I can build it on my
 system, but it will also work well when distributed to other computers (if I
 understand the package process well, source files are compiled and linked
 during installation of the package), so I would also like to know how to do
 this.

 It should not be relevant, but either way: I'm doing all this on a Windows 7
 machine, though the package will probably be used on Linux-based servers
 eventually.

 Finally: I have found no comprehensive list of the functions available to an
 R package developer, nor, strangely, questions about that. Does such a thing
 exist, or are we up to hoping we find what we are looking for in the header
 files? If it does not exist already, I would surely be willing to work on
 it.

Do you mean other than the section on The R API in the Writing R
Extensions manual?
 Thanks for any input.

 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36

 -- Do Not Disapprove

 __
 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] R-2.12.0 hangs while loading RGtk2 on FreeBSD

2010-10-22 Thread Michael Lawrence
On Thu, Oct 21, 2010 at 9:42 AM, Rainer Hurling rhur...@gwdg.de wrote:

 [moved from R-help]

 On 21.10.2010 18:09 (UTC+1), Prof Brian Ripley wrote:

 If you do R CMD INSTALL --no-test-load this will skip the part that is
 hanging and you can try loading in stages (e.g. dyn.load on the RGtk2.so).


 With '--no-test-load' it installs and ends normal. Loading per
 dyn.load(RGtk2.so) works, just as dyn.load(RGtk2.so,F) and
 dyn.load(RGtk2.so,,F). Unloading works, too.

 Normal loading over library(RGtk2) within R does not work. R than is
 hanging.

 It seems the problem is not with the library itself?


It looks like something is happening when initializing GTK+ and the event
loop. This happens in the function R_gtkInit in Rgtk.c. If you could run R
-d gdb and break on that function, perhaps you could step through until it
hangs.

Thanks,
Michael


  I think this is rather technical for R-help, so maybe move to R-devel?


 I moved to R-devel.

  And can you check the RGtk2 version? A recent but not current version
 (2.12.17?) did hang initializing Gtk+ on some platforms and Michael
 Lawrence had to be involved.


 I am using RGtk2_2.12.18.tar.gz for month now.


  On Thu, 21 Oct 2010, Rainer Hurling wrote:

  Am 21.10.2010 16:12 (UTC+1) schrieb Prof Brian Ripley:

 On Thu, 21 Oct 2010, Rainer Hurling wrote:

  I am working with R-2.12.0 on FreeBSD 9.0-CURRENT for a while now. I
 successfully installed more than 300 packages (most as dependencies of
 others).

 There are two packages I am not able to install: RGtk2 and rggobi.

 For example rggobi builds fine and after that it wants to load:

 --
 # R CMD INSTALL rggobi_2.1.16.tar.gz
 [..SNIP..]
 gcc -std=gnu99 -shared -L/usr/local/lib -o rggobi.so RSEval.o brush.o
 colorSchemes.o conversion.o data.o dataset.o display.o displays.o
 edges.o ggobi.o identify.o init.o io.o keyHandlers.o longitudinal.o
 modes.o plot.o plots.o plugins.o print.o session.o smooth.o ui.o
 utils.o -pthread -L/usr/local/lib -lggobi -lgtk-x11-2.0 -lxml2
 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lXext
 -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage
 -lpangoft2-1.0 -lgio-2.0 -lXfixes -lcairo -lX11 -lpango-1.0 -lm
 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0
 -lglib-2.0
 installiert nach /usr/local/lib/R/library/rggobi/libs
 ** R
 ** data
 ** moving datasets to lazyload DB
 ** demo
 ** preparing package for lazy loading
 --

 At this point the install process is hanging, R utilises no more CPU
 time. Same with package RGtk2.

 Is this a known error? Please let me know if I can give more
 information or try something different.


 Well, those are exactly the two packages using Gtk+.

 There is no known general problem, and as you could have checked from
 the CRAN check pages, those packages install without problems on several
 platforms. (Not Solaris, where ggobi does not install and RGtk2 requires
 gcc, and not x64 Windows where both need to be patched.)

 So it does look very like there is a problem with loading against the
 Gtk+ system libraries on your system.


 I think you are right. With previous versions of R (until R-2.10.x) I
 did not have this hanging when loading RGtk2 ... And I am pretty sure
 that I have no problems with gtk2 outside of R on my FreeBSD system.

 In the meantime I found out that the reported loading error of rggobi
 is a loading error of RGtk2, which fails (hangs). So there remains
 only a loading error with RGtk2. (Because of that I changed the subject.)

 After building/installing RGtk2, there are the following messages:

 --
 [..SNIP..]
 gcc -std=gnu99 -shared -L/usr/local/lib -o RGtk2.so RGtkDataFrame.o
 Rgtk.o atkAccessors.o atkClasses.o atkConversion.o atkFuncs.o
 atkManuals.o atkUserFuncs.o cairo-enums.o cairoAccessors.o
 cairoConversion.o cairoFuncs.o cairoManuals.o cairoUserFuncs.o
 classes.o conversion.o eventLoop.o gdkAccessors.o gdkClasses.o
 gdkConversion.o gdkFuncs.o gdkManuals.o gdkUserFuncs.o glib.o
 gobject.o gtkAccessors.o gtkClasses.o gtkConversion.o gtkFuncs.o
 gtkManuals.o gtkUserFuncs.o libgladeAccessors.o libgladeFuncs.o
 libgladeManuals.o libgladeUserFuncs.o pangoAccessors.o pangoClasses.o
 pangoConversion.o pangoFuncs.o pangoManuals.o pangoUserFuncs.o utils.o
 zcompat.o -pthread -L/usr/local/lib -lglade-2.0 -lgtk-x11-2.0 -lxml2
 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lXext
 -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage
 -lpangoft2-1.0 -lgio-2.0 -lXfixes -lcairo -lX11 -lpango-1.0 -lm
 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0
 -lglib-2.0 -pthread -L/usr/local/lib -lgthread-2.0 -lglib-2.0
 installiert nach /usr/local/lib/R/library/RGtk2/libs
 ** R
 ** demo
 ** inst
 ** preparing package for lazy loading
 ** help
 *** installing help indices
 ** building package 

Re: [Rd] Linking to lapack

2010-10-22 Thread Matt Shotwell
On Fri, 2010-10-22 at 05:30 -0400, Nick Sabbe wrote:
 Hello all.
 
 I'm developing a package for R holding a Gibbs sampler, which tends to have
 better performance when written in C than in R.
 During each iteration in the Gibbs sampler, I need the inverse of a
 symmetric matrix.
 For this, I wish to use lapack, as is concisely suggested in Writing R
 extensions, since this will have better performance than I could ever write
 myself.
 
 After some twiddling I have got my code to compile by including
 R_ext/Lapack.h and using F77_CALL(dpotrf), but unfortunately, I don't
 get this to link properly.
 I get this message:  testc.o:testc.c:(.text+0x255): undefined reference to
 `dpotrf_' which seems logical to me as far as my understanding of C
 reaches, but I don't know how to resolve it. I'm quite sure I need some
 extra parameters in my makefile, but as I come from a world where all these
 complexities are happily abstracted away for me by an IDE, I have no actual
 clue on how to surmount this.

Yes. You need to ensure that your program is linked with a Lapack
library where the symbol dpotrf_ is defined. In an R package, using a
'Makevars' file in your 'src' directory is used to specify additional
linking. See Writing R Extensions section 1.2.1 Using ‘Makevars’. If
you are compiling your code with a custom Makefile, then you will need
to add an argument to the linker/compiler specifying a Lapack library to
be linked. For example, here is a command that dynamically links the R
Lapack and Blas libraries to a pre-compiled 'test.o' on my system:

gcc -std=gnu99 -shared -L/usr/local/lib -o test.so test.o
-L/usr/local/lib/R/lib -lRlapack -L/usr/local/lib/R/lib -lRblas
-lgfortran -lm

 However: when I'm done with all my code, I wish to build a package for
 publication on CRAN, so I want to be sure that not only I can build it on my
 system, but it will also work well when distributed to other computers (if I
 understand the package process well, source files are compiled and linked
 during installation of the package), so I would also like to know how to do
 this.

It might be a good idea to build your package simultaneously with your
code, and use a Makevars file.

 It should not be relevant, but either way: I'm doing all this on a Windows 7
 machine, though the package will probably be used on Linux-based servers
 eventually.
 
 Finally: I have found no comprehensive list of the functions available to an
 R package developer, nor, strangely, questions about that. Does such a thing
 exist, or are we up to hoping we find what we are looking for in the header
 files? If it does not exist already, I would surely be willing to work on
 it.

Three of the R manuals (R-exts, R-ints, R-admin;
http://cran.r-project.org/doc/manuals/) partially describe some aspect
of the R API, where Writing R Extensions is the most comprehensive.
Function descriptions are generally not biolerplate. For good or bad, a
look into the C headers is often necessary to use an R API function.

-Matt

 Thanks for any input.
 
 Nick Sabbe
 --
 ping: nick.sa...@ugent.be
 link: http://biomath.ugent.be
 wink: A1.056, Coupure Links 653, 9000 Gent
 ring: 09/264.59.36
 
 -- Do Not Disapprove
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Matthew S. Shotwell
Graduate Student 
Division of Biostatistics and Epidemiology
Medical University of South Carolina

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


Re: [Rd] [R] R-2.12.0 hangs while loading RGtk2 on FreeBSD

2010-10-22 Thread Rainer Hurling

On 22.10.2010 14:57 (UTC+1), Michael Lawrence wrote:



On Thu, Oct 21, 2010 at 9:42 AM, Rainer Hurling rhur...@gwdg.de
mailto:rhur...@gwdg.de wrote:

[moved from R-help]

On 21.10.2010 18:09 (UTC+1), Prof Brian Ripley wrote:

If you do R CMD INSTALL --no-test-load this will skip the part
that is
hanging and you can try loading in stages (e.g. dyn.load on the
RGtk2.so).


With '--no-test-load' it installs and ends normal. Loading per
dyn.load(RGtk2.so) works, just as dyn.load(RGtk2.so,F) and
dyn.load(RGtk2.so,,F). Unloading works, too.

Normal loading over library(RGtk2) within R does not work. R than is
hanging.

It seems the problem is not with the library itself?


It looks like something is happening when initializing GTK+ and the
event loop. This happens in the function R_gtkInit in Rgtk.c. If you
could run R -d gdb and break on that function, perhaps you could step
through until it hangs.


Michael, thank you for answering. As I wrote earlier (on R-help@), 
unfortunately I have no experience with debugging (I am not a 
programmer). So I would need some more assistence.


Is  there a difference between 'library(RGtk2)' and 'dyn.load(RGtk2)' in 
initializing GTK+? I am able to dyn.load, but library does not work.


After starting with 'R -d gdb' is the following right?

  (gdb) break R_gtkInit
  Function R_gtkInit not defined.
  Make breakpoint pending on future shared library load? (y or [n]) y
  Breakpoint 1 (R_gtkInit) pending.

When I try to proceed, it gives me the following message

  (gdb) run
  Starting program: /usr/local/lib/R/bin/exec/R
  /libexec/ld-elf.so.1: Shared object libRblas.so not found,
  required by R
  Program exited with code 01.

Obviously there is some wrong with my try?

Thanks again,
Rainer



Thanks,
Michael

I think this is rather technical for R-help, so maybe move to
R-devel?


I moved to R-devel.

And can you check the RGtk2 version? A recent but not current
version
(2.12.17?) did hang initializing Gtk+ on some platforms and Michael
Lawrence had to be involved.


I am using RGtk2_2.12.18.tar.gz for month now.


On Thu, 21 Oct 2010, Rainer Hurling wrote:

Am 21.10.2010 16:12 (UTC+1) schrieb Prof Brian Ripley:

On Thu, 21 Oct 2010, Rainer Hurling wrote:

I am working with R-2.12.0 on FreeBSD 9.0-CURRENT
for a while now. I
successfully installed more than 300 packages (most
as dependencies of
others).

There are two packages I am not able to install:
RGtk2 and rggobi.

For example rggobi builds fine and after that it
wants to load:

--
# R CMD INSTALL rggobi_2.1.16.tar.gz
[..SNIP..]
gcc -std=gnu99 -shared -L/usr/local/lib -o rggobi.so
RSEval.o brush.o
colorSchemes.o conversion.o data.o dataset.o
display.o displays.o
edges.o ggobi.o identify.o init.o io.o keyHandlers.o
longitudinal.o
modes.o plot.o plots.o plugins.o print.o session.o
smooth.o ui.o
utils.o -pthread -L/usr/local/lib -lggobi
-lgtk-x11-2.0 -lxml2
-lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0
-lpangocairo-1.0 -lXext
-lXrender -lXinerama -lXi -lXrandr -lXcursor
-lXcomposite -lXdamage
-lpangoft2-1.0 -lgio-2.0 -lXfixes -lcairo -lX11
-lpango-1.0 -lm
-lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0
-lgthread-2.0
-lglib-2.0
installiert nach /usr/local/lib/R/library/rggobi/libs
** R
** data
** moving datasets to lazyload DB
** demo
** preparing package for lazy loading
--

At this point the install process is hanging, R
utilises no more CPU
time. Same with package RGtk2.

Is this a known error? Please let me know if I can
give more
information or try something different.


Well, those are exactly the two packages using Gtk+.

There is no known general problem, and as you could have
checked from
the CRAN check pages, those packages install without
problems on several
platforms. (Not Solaris, where ggobi does 

[Rd] Reference classes

2010-10-22 Thread Jon Clayden
Dear all,

First, many thanks to John Chambers, and anyone else who was involved,
for the new support for reference classes in R 2.12.0. It's nice to
see this kind of functionality appear in a relatively R-like form, and
with the blessing of the core team. In some contexts it is undoubtedly
appealing to associate a set of methods with a class directly, rather
than defining a load of generics which are only ever likely to be
implemented for a single class, or some other such arrangement. (I was
actually in the process of writing a package which did something
similar to the reference class idea, although it is less fully
realised.)

My initial experiences with this functionality have been very
positive. I've stumbled over one minor issue so far: default values of
method parameters are not displayed by the help() method, viz.

 library(methods)
 Regex - setRefClass(Regex, fields=string, methods=list(
+ isMatch = function (text, ignoreCase = FALSE)
+ {
+ 'Returns a logical vector of the same length as text,
indicating whether or not each element is a match to the regular
expression.'
+ grepl(string, text, ignore.case=ignoreCase, perl=TRUE)
+ }
+ ))
 Regex$help(isMatch)
Call: $isMatch(text, ignoreCase = )

Returns a logical vector of the same length as text, indicating
whether or not each element is a match to the regular expression.

It seems unlikely that this is intentional, but correct me if I'm
wrong. It still seems to happen with the latest R-patched (Mac OS X
10.5.8).

As a suggestion, it would be nice if the accessors() method could be
used to create just getters or just setters for particular fields,
although I realise this can be worked around by removing the unwanted
methods afterwards.

More generally, I was wondering how firm the commitment is to
providing this kind of programming mechanism. I know it's likely to
change in some ways in future releases, but can I use it in packages,
trusting that only a few tweaks will be needed for compatibility with
future versions of R, or is it possible that the whole infrastructure
will be removed in future?

All the best,
Jon

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


[Rd] CRAN: Windows builds/pages outdated?

2010-10-22 Thread Henrik Bengtsson
FYI, in case you are not aware of it,

both

http://cran.r-project.org/bin/windows/base/rpatched.html
http://cran.r-project.org/bin/windows/base/rdevel.html

link to old builds (2010-10-14 r53300).

/Henrik

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


Re: [Rd] new.env does not recognize parents from subclassesof environment

2010-10-22 Thread Vitally S.

Yet another inconsistency. environment- does not work with S4:


 setClass(myenv, contains = environment)
[1] myenv
 env - new(myenv)
 tf - function(x){x}
 environment(tf) - env
Error in environment(tf) - env : 
  replacement object is not an environment


Vitally.


John Chambers j...@stanford.edu writes:
  This is a problem related to the introduction of exact= into the [[ and [[- 
 functions. As Bill says, the current
 method misuses eval.parent() when that argument is added.

 However, a simpler and more efficient solution is to migrate the checks for 
 subclasses of environment used in
 other base code into the code for [[- (and for $-), at which point the 
 methods for these functions are no longer
 needed.

 A solution on these lines is being tested now and will find its way into 
 r-devel and 2.12 patched.

 One other point about the original posting:

 Please don't use constructions like e...@.xdata. This depends on the current 
 implementation and is not part of the
 user-level definition. Use as(env, environment) or equivalent. (In this 
 case, the assignment of the object's own
 environment was irrelevant to the error.)

 John Chambers

 On 10/21/10 9:21 AM, William Dunlap wrote:
 The traceback looks very similar to a problem
 in R 2.11.1 reported earlier this month by Troy Robertson.
  From: r-devel-boun...@r-project.org
  [mailto:r-devel-boun...@r-project.org] On Behalf Of Troy Robertson
  Sent: Wednesday, October 06, 2010 6:13 PM
  To: 'r-devel@R-project.org'
  Subject: Re: [Rd] Recursion error after upgrade to
  R_2.11.1[Sec=Unclassified]
 It was due to a miscount of how many frames to go
 up before evaluating an expression in
 getMethod([[-,.environment) because setMethod()
 introduced a local function in the new method.

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 -Original Message-
 From: r-devel-boun...@r-project.org
 [mailto:r-devel-boun...@r-project.org] On Behalf Of Vitally S.
 Sent: Thursday, October 21, 2010 9:00 AM
 To: John Chambers
 Cc: r-devel@r-project.org
 Subject: Re: [Rd] new.env does not recognize parents from
 subclassesof environment



 Here is an infinite recursion error  which occurs only with S4
 subclasses assignment.

   setClass(myenv, contains = environment)
 #[1] myenv
   env- new(myenv)
   env[[.me]]- ∑
 #Error: evaluation nested too deeply: infinite recursion /
 options(expressions=)?


 With basic types it works as expected:

 env1- new.env()
 env1[[.me]]- env1

 May be this is related to active bindings that you mentioned,
   but I am still
 reporting it here.

 Vitally.


   Thanks for the report.  Should now be fixed in r-devel and
 2.12 patched (rev 53383).
 Please do report any cases where a subclass of environment
 doesn't work.  There are some known cases in locking and
 active binding, that will be fixed in due course.

 The workaround for any such problem is usually as.environment().

 On 10/20/10 3:17 AM, Vitaly S. wrote:
 Dear Developers,

 A lot has been changed in the R12.0 with respect to
 behavior of environment
 subclasses.  Many thanks for that.

 One small irregularity, though; new.env does not allow the
 parent to be from S4
 subclass.


 setClass(myenv, contains=environment)
 [1] myenv
 new.env(parent=new(myenv))
 Error in new.env(parent = new(myenv)) : 'enclos' must be
 an environment
 I wonder if this is a planed behavior.

 The use of .xData  slot obviously works:
 new.env(parent=new(myenv)@.xData)
 environment: 063bb9e8
 Thanks,
 Vitaly.

 __
 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

 __
 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] Reference classes

2010-10-22 Thread John Chambers

Last question first:


 More generally, I was wondering how firm the commitment is to
 providing this kind of programming mechanism. I know it's likely to
 change in some ways in future releases, but can I use it in packages,
 trusting that only a few tweaks will be needed for compatibility with
 future versions of R, or is it possible that the whole infrastructure
 will be removed in future?


Speaking just for myself, I'd say it's pretty solid.  Reasons:

 - it's essentially an add-on and essentially all R code, so as long as 
there is some interest, it's not hurting other code--it builds directly 
on some valuable existing tools for environments, such as active bindings;


 - this is something I've wanted to do for a while.  The essential step 
was being able to subclass environments, and that has been in place for 
some time now;


 - initial experience has been largely positive.  The Rcpp package in 
its newest version depends on reference classes.


Now as to what tweaks will be needed, that remains to be seen.  But my 
guess is that most will be issues of implementation.  The user interface 
is sufficiently standardized among languages that it has a reasonable 
chance to stay compatible.


Other comments below.

John


On 10/22/10 7:21 AM, Jon Clayden wrote:

Dear all,

First, many thanks to John Chambers, and anyone else who was involved,
for the new support for reference classes in R 2.12.0. It's nice to
see this kind of functionality appear in a relatively R-like form, and
with the blessing of the core team. In some contexts it is undoubtedly
appealing to associate a set of methods with a class directly, rather
than defining a load of generics which are only ever likely to be
implemented for a single class, or some other such arrangement. (I was
actually in the process of writing a package which did something
similar to the reference class idea, although it is less fully
realised.)

My initial experiences with this functionality have been very
positive. I've stumbled over one minor issue so far: default values of
method parameters are not displayed by the help() method, viz.


library(methods)
Regex- setRefClass(Regex, fields=string, methods=list(

+ isMatch = function (text, ignoreCase = FALSE)
+ {
+ 'Returns a logical vector of the same length as text,
indicating whether or not each element is a match to the regular
expression.'
+ grepl(string, text, ignore.case=ignoreCase, perl=TRUE)
+ }
+ ))

Regex$help(isMatch)

Call: $isMatch(text, ignoreCase = )

Returns a logical vector of the same length as text, indicating
whether or not each element is a match to the regular expression.

It seems unlikely that this is intentional, but correct me if I'm
wrong. It still seems to happen with the latest R-patched (Mac OS X
10.5.8).


It's a bug.


As a suggestion, it would be nice if the accessors() method could be
used to create just getters or just setters for particular fields,
although I realise this can be worked around by removing the unwanted
methods afterwards.


In other words, read-only fields.  There is a facility for that 
implemented already, but it didn't yet make it into the documentation, 
and it could use some more testing.  The generator object has a $lock() 
method that inserts a write-once type of method for one or more fields. 
 Example:


 fg - setRefClass(foo, list(bar = numeric, flag = character),
+ methods = list(
+ addToBar = function(incr) {
+ b = bar + incr
+ bar - b
+ b
+ }
+ ))
 fg$lock(bar)
 ff = new(foo, bar = 1.5)
 ff$bar - 2
Error in function (value)  : Field bar is read-only

A revision will document this soon.

(And no, the workaround is not to remove methods.  To customize access 
to a field, the technique is to write an accessor function for the field 
that, in this case, throws an error if it gets an argument.  See the 
documentation for the fields argument.  The convention here and the 
underlying mechanism are taken from active bindings for environments.)




More generally, I was wondering how firm the commitment is to
providing this kind of programming mechanism. I know it's likely to
change in some ways in future releases, but can I use it in packages,
trusting that only a few tweaks will be needed for compatibility with
future versions of R, or is it possible that the whole infrastructure
will be removed in future?

All the best,
Jon

__
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] Reference classes

2010-10-22 Thread John Chambers

One correction:

On 10/22/10 10:55 AM, John Chambers wrote:
.


As a suggestion, it would be nice if the accessors() method could be
used to create just getters or just setters for particular fields,
although I realise this can be worked around by removing the unwanted
methods afterwards.


In other words, read-only fields. There is a facility for that
implemented already, but it didn't yet make it into the documentation,
and it could use some more testing. The generator object has a $lock()
method that inserts a write-once type of method for one or more fields.
Example:

  fg - setRefClass(foo, list(bar = numeric, flag = character),
+ methods = list(
+ addToBar = function(incr) {
+ b = bar + incr
+ bar - b
+ b
+ }
+ ))
  fg$lock(bar)
  ff = new(foo, bar = 1.5)
  ff$bar - 2
Error in function (value) : Field bar is read-only




Actually it is documented in the section on generator objects.  But 
since I also didn't see it, maybe it needs an example.  ;-)


John

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


Re: [Rd] new.env does not recognize parents from subclassesof environment

2010-10-22 Thread Vitally S.



John Chambers j...@stanford.edu writes:

  You need to update your version of R (r-devel or 2.12 patched) to rev
 53385 or later, and read NEWS, particularly the line:

 - Assignment of an environment to functions or as an attribute to other
 objects now works for subclasses of environment.


I am following the news in daily snapshots from here
ftp://ftp.stat.math.ethz.ch/Software/R
and  the above line is still not in the NEWS of today's version.

Thanks for the patch. Looking forward to the stable release.

Vitally.

 On 10/22/10 10:20 AM, Vitally S. wrote:
 Yet another inconsistency. environment- does not work with S4:


 setClass(myenv, contains = environment)
 [1] myenv
 env - new(myenv)
 tf - function(x){x}
 environment(tf) - env
 Error in environment(tf) - env : 
   replacement object is not an environment


 Vitally.


 John Chambers j...@stanford.edu writes:
 This is a problem related to the introduction of exact= into the [[ and 
 [[- functions. As Bill says, the
 current
 method misuses eval.parent() when that argument is added.

 However, a simpler and more efficient solution is to migrate the checks for 
 subclasses of environment used in
 other base code into the code for [[- (and for $-), at which point the 
 methods for these functions are no
 longer
 needed.

 A solution on these lines is being tested now and will find its way into 
 r-devel and 2.12 patched.

 One other point about the original posting:

 Please don't use constructions like e...@.xdata. This depends on the 
 current implementation and is not part of
 the
 user-level definition. Use as(env, environment) or equivalent. (In this 
 case, the assignment of the object's
 own
 environment was irrelevant to the error.)

 John Chambers

 On 10/21/10 9:21 AM, William Dunlap wrote:
 The traceback looks very similar to a problem
 in R 2.11.1 reported earlier this month by Troy Robertson.
  From: r-devel-boun...@r-project.org
  [mailto:r-devel-boun...@r-project.org] On Behalf Of Troy Robertson
  Sent: Wednesday, October 06, 2010 6:13 PM
  To: 'r-devel@R-project.org'
  Subject: Re: [Rd] Recursion error after upgrade to
  R_2.11.1[Sec=Unclassified]
 It was due to a miscount of how many frames to go
 up before evaluating an expression in
 getMethod([[-,.environment) because setMethod()
 introduced a local function in the new method.

 Bill Dunlap
 Spotfire, TIBCO Software
 wdunlap tibco.com

 -Original Message-
 From: r-devel-boun...@r-project.org
 [mailto:r-devel-boun...@r-project.org] On Behalf Of Vitally S.
 Sent: Thursday, October 21, 2010 9:00 AM
 To: John Chambers
 Cc: r-devel@r-project.org
 Subject: Re: [Rd] new.env does not recognize parents from
 subclassesof environment



 Here is an infinite recursion error  which occurs only with S4
 subclasses assignment.

   setClass(myenv, contains = environment)
 #[1] myenv
   env- new(myenv)
   env[[.me]]- ∑
 #Error: evaluation nested too deeply: infinite recursion /
 options(expressions=)?


 With basic types it works as expected:

 env1- new.env()
 env1[[.me]]- env1

 May be this is related to active bindings that you mentioned,
   but I am still
 reporting it here.

 Vitally.


   Thanks for the report.  Should now be fixed in r-devel and
 2.12 patched (rev 53383).
 Please do report any cases where a subclass of environment
 doesn't work.  There are some known cases in locking and
 active binding, that will be fixed in due course.

 The workaround for any such problem is usually as.environment().

 On 10/20/10 3:17 AM, Vitaly S. wrote:
 Dear Developers,

 A lot has been changed in the R12.0 with respect to
 behavior of environment
 subclasses.  Many thanks for that.

 One small irregularity, though; new.env does not allow the
 parent to be from S4
 subclass.


 setClass(myenv, contains=environment)
 [1] myenv
 new.env(parent=new(myenv))
 Error in new.env(parent = new(myenv)) : 'enclos' must be
 an environment
 I wonder if this is a planed behavior.

 The use of .xData  slot obviously works:
 new.env(parent=new(myenv)@.xData)
 environment: 063bb9e8
 Thanks,
 Vitaly.

 __
 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 
 __
 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

 __
 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] R-2.12.0 hangs while loading RGtk2 on FreeBSD

2010-10-22 Thread Rainer Hurling

On 22.10.2010 16:18 (UTC+2), Rainer Hurling wrote:

On 22.10.2010 14:57 (UTC+1), Michael Lawrence wrote:



On Thu, Oct 21, 2010 at 9:42 AM, Rainer Hurling rhur...@gwdg.de
mailto:rhur...@gwdg.de wrote:

[moved from R-help]

On 21.10.2010 18:09 (UTC+1), Prof Brian Ripley wrote:

If you do R CMD INSTALL --no-test-load this will skip the part
that is
hanging and you can try loading in stages (e.g. dyn.load on the
RGtk2.so).


With '--no-test-load' it installs and ends normal. Loading per
dyn.load(RGtk2.so) works, just as dyn.load(RGtk2.so,F) and
dyn.load(RGtk2.so,,F). Unloading works, too.

Normal loading over library(RGtk2) within R does not work. R than is
hanging.

It seems the problem is not with the library itself?


It looks like something is happening when initializing GTK+ and the
event loop. This happens in the function R_gtkInit in Rgtk.c. If you
could run R -d gdb and break on that function, perhaps you could step
through until it hangs.


Michael, thank you for answering. As I wrote earlier (on R-help@),
unfortunately I have no experience with debugging (I am not a
programmer). So I would need some more assistence.

Is there a difference between 'library(RGtk2)' and 'dyn.load(RGtk2)' in
initializing GTK+? I am able to dyn.load, but library does not work.

After starting with 'R -d gdb' is the following right?

(gdb) break R_gtkInit
Function R_gtkInit not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (R_gtkInit) pending.

When I try to proceed, it gives me the following message

(gdb) run
Starting program: /usr/local/lib/R/bin/exec/R
/libexec/ld-elf.so.1: Shared object libRblas.so not found,
required by R
Program exited with code 01.


Ok, I am one step further now:


(gdb) run
Starting program: /usr/local/lib/R/bin/exec/R
[..SNIP..]
 library(RGtk2)
[New LWP 100174]
Breakpoint 2 at 0x318bd490: file Rgtk.c, line 104.
Pending breakpoint R_gtkInit resolved
[New Thread 2f408b00 (LWP 100174)]
[Switching to Thread 2f408b00 (LWP 100174)]

Breakpoint 2, R_gtkInit (rargc=0x30b11d10, rargv=0x30a98458, 
success=0x30afbad0) at Rgtk.c:104

104 Rgtk.c: No such file or directory.
in Rgtk.c
(gdb)


What do you suggest I should do next?



Thanks again,
Rainer



Thanks,
Michael

I think this is rather technical for R-help, so maybe move to
R-devel?


I moved to R-devel.

And can you check the RGtk2 version? A recent but not current
version
(2.12.17?) did hang initializing Gtk+ on some platforms and Michael
Lawrence had to be involved.


I am using RGtk2_2.12.18.tar.gz for month now.


On Thu, 21 Oct 2010, Rainer Hurling wrote:

Am 21.10.2010 16:12 (UTC+1) schrieb Prof Brian Ripley:

On Thu, 21 Oct 2010, Rainer Hurling wrote:

I am working with R-2.12.0 on FreeBSD 9.0-CURRENT
for a while now. I
successfully installed more than 300 packages (most
as dependencies of
others).

There are two packages I am not able to install:
RGtk2 and rggobi.

For example rggobi builds fine and after that it
wants to load:

--
# R CMD INSTALL rggobi_2.1.16.tar.gz
[..SNIP..]
gcc -std=gnu99 -shared -L/usr/local/lib -o rggobi.so
RSEval.o brush.o
colorSchemes.o conversion.o data.o dataset.o
display.o displays.o
edges.o ggobi.o identify.o init.o io.o keyHandlers.o
longitudinal.o
modes.o plot.o plots.o plugins.o print.o session.o
smooth.o ui.o
utils.o -pthread -L/usr/local/lib -lggobi
-lgtk-x11-2.0 -lxml2
-lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0
-lpangocairo-1.0 -lXext
-lXrender -lXinerama -lXi -lXrandr -lXcursor
-lXcomposite -lXdamage
-lpangoft2-1.0 -lgio-2.0 -lXfixes -lcairo -lX11
-lpango-1.0 -lm
-lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0
-lgthread-2.0
-lglib-2.0
installiert nach /usr/local/lib/R/library/rggobi/libs
** R
** data
** moving datasets to lazyload DB
** demo
** preparing package for lazy loading
--

At this point the install process is hanging, R
utilises no more CPU
time. Same with package RGtk2.

Is this a known error? Please let me know if I can
give more
information or try something different.


Well, those are exactly the two packages using Gtk+.

There is no known general problem, and as you could have
checked from
the CRAN check pages, those packages install without
problems on several
platforms. (Not Solaris, where ggobi does not install
and RGtk2 requires
gcc, and not x64 Windows where both need to be patched.)

So it does look very like there is a problem with
loading against the
Gtk+ system libraries on your system.


I think you are right. With previous versions of R (until
R-2.10.x) I
did not have this hanging when loading RGtk2 ... And I am
pretty sure
that I have no problems with gtk2 outside of R on my FreeBSD
system.

In the meantime I found out that the reported loading error
of rggobi
is a loading error of RGtk2, which fails (hangs). So there
remains
only a loading error with RGtk2. (Because of that I changed
the subject.)

After 

Re: [Rd] Reference classes

2010-10-22 Thread Jon Clayden
On 22 October 2010 18:55, John Chambers j...@r-project.org wrote:

 As a suggestion, it would be nice if the accessors() method could be
 used to create just getters or just setters for particular fields,
 although I realise this can be worked around by removing the unwanted
 methods afterwards.

 In other words, read-only fields.  There is a facility for that implemented
 already, but it didn't yet make it into the documentation, and it could use
 some more testing.  The generator object has a $lock() method that inserts a
 write-once type of method for one or more fields.  Example:

 fg - setRefClass(foo, list(bar = numeric, flag = character),
 +             methods = list(
 +             addToBar = function(incr) {
 +                 b = bar + incr
 +                 bar - b
 +                 b
 +             }
 +             ))
 fg$lock(bar)
 ff = new(foo, bar = 1.5)
 ff$bar - 2
 Error in function (value)  : Field bar is read-only

 A revision will document this soon.

 (And no, the workaround is not to remove methods.  To customize access to a
 field, the technique is to write an accessor function for the field that, in
 this case, throws an error if it gets an argument.  See the documentation
 for the fields argument.  The convention here and the underlying mechanism
 are taken from active bindings for environments.)

OK, yes - I see. This is clearly much less superficial than removing
the setter method for a field which can be directly set anyway. I'll
have to try out field accessor functions and get a feel for the
semantics.

Many thanks for the rapid and very helpful response.

Regards,
Jon

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


[Rd] possible error checking bug and documentation bug in ts

2010-10-22 Thread Charles Geyer
The documentation for ts says Only one of ‘frequency’ or ‘deltat’ should
be provided but why doesn't it enforce this with

    stopifnot(missing(frequency) || missing(deltat))

Wouldn't that work?  Also the documentation does not say what valid
time series parameters are.  To find that out one must know to RTFS
in src/main/attrib.c and find that

    end - start  = (n - 1) / frequency

or

   end - start  = (n - 1)  * deltat

is required to avoid an error, where
n is either length(data) or nrow(data).
Why can the help page for ts say that?

I suppose this is picky, but a newbie just wasted a couple of days
with the mysterious error thrown in badtsp in src/main/attrib.c
when he ran afoul of R's argument matching rules and
unintentionally supplied both frequency and deltat (thinking he
was supplying deltat and ts.eps).  It took me more time that it
should have to figure it out too.
--
Charles Geyer
Professor, School of Statistics
University of Minnesota
char...@stat.umn.edu

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