[Rd] R CMD check: Undocumented class for class created with setOldClass()

2011-11-18 Thread Andreas Borg

Hi all,

in a package, I register two S3 classes (namely ff_vector and ffdf) by 
calling setOldClass() in order to use them as slots in S4 classes. Now, 
R CMD check gives me the warning:


Undocumented S4 classes:
 'ff_vector' 'ffdf'

Is there a way to avoid having to document classes I did not write? Or 
is this intended behaviour?


Best regards,

Andreas

--
Andreas Borg
Abteilung Medizinische Informatik

Universitätsmedizin der Johannes Gutenberg-Universität Mainz
Institut für Med. Biometrie, Epidemiologie und Informatik (IMBEI)
Obere Zahlbacher Straße 69, 55131 Mainz

Tel:  +49 (0) 6131 17-5062

E-Mail: andreas.b...@uni-mainz.de

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


Re: [Rd] Reproducible use case for R crash after updating R

2011-05-18 Thread Andreas Borg

Hi all,

I'd like to add another suggestion:

Henrik Bengtsson schrieb:

6. User starts R.  R crashes with Fatal error: unable to restore
saved object in .RData because 'fortunes' is not installed for this
new version of R.  There is also an error message before that
reporting Error in loadNamespace(name) : there is no package called
'fortunes'.

  
I would find it very useful if the installer offered an option to copy 
extension packages from the old version to the new version. Apart from 
possibly preventing this type of crash, it would save the hassle of 
reinstalling or copying the extension packages one regularly uses.


Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] [R] Sweave stops when opening X11 device fails

2011-05-03 Thread Andreas Borg

Hi all,

I am posting this again because I got no reply on r-help. Maybe the 
devel-list is the right place for this kind of question.


I've run into the following problem with Sweave: I frequently run Sweave
from a xterm console within an X session owned by a different user, i.e.
my colleague is logged in on this computer and I do su with my
username and start R and Sweave afterwards. Now, when Sweave comes to a
figure chunk, it sees that there is an X server running and tries to
show whatever I plot in that chunk on the screen, additionally to
writing a pdf file. The problem is that I am not logged into the X
session myself, and the script fails with a message saying someting like
could not open device X11 (I have German messages, so I do not know
what the exact phrase would be in English). When I log in with putty,
where there is no X11 at all, everything works fine. Is there a way to
prevent Sweave from failing in the former case? Would this even account
as a bug? I think it would be nice if the script just kept on running
without plotting on the screen if opening X11 fails, just like it does
when no X11 is available at all.

Best regards,

Andreas

p.s.: I would be willing to dig in the code and look for a fix myself, 
but it would be great if anyone could give a hint where to look. I 
suspect RweaveDriverRuncode is the right place, but in what namespace 
is it?


--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte 
Informationen. Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, 
informieren Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe

dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

__
r-h...@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

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


Re: [Rd] super basic questions about S4 classes

2011-04-08 Thread Andreas Borg

Hi Andre,

1. Keep in mind that a S4 method belongs to a specific generic function,
not to a specific object or class. There is none such thing as a class
member function in the S4 system. As an example for illustration,
consider the following class definitions in Java:

class myClassA
{
   int a;
   int myMethod();
}

class myClassB
{
   double b;
int myMethod()
}

Assuming that myClassA and myClassB are not related by inheritance, the
two instances of myMethod have nothing to do with each other. With S4
classes, you would have something like:

setClass(myClassA, representation(a=integer))
setClass(myClassB, representation(b=numeric))

setGeneric(myMethod, function(x) standardGeneric(myMethod))
setMethod(myMethod, myClassA, function(x) {myMethodA})
setMethod(myMethod, myClassB, function(x) {myMethodB})

where the instances of myMethod belong to the same generic function.
Note that because the methods do not belong to a specific class /
object, the object on which to call must be passed as argument.
Futhermore, it is impossible to have a method with a different argument
list than the generic. Based on the code above, the following gives an
error:

setClass(myClassC, representation(c=character))
setMethod(myMethod, myClassC, function(x,y) {myMethodC})

while in Java it is no problem to have

class myClassC
{
   char c[];
   int myMethod(int x, int y)
}

with a different argument list for myMethod.

(Of course, different argument lists in methods are possible if one uses
... in the generic, this example was just meant as an illustration of
the conceptual difference between class methods and generic functions.)

There is a new approach in R called reference classes, which might
provide what you are looking for. But I am not familiar with this
paradigm. See ?ReferenceClasses.

2. A function in R is stored in a variable of the same name - as there
can be only one variable with a distinct name (within the same scope),
no overloading is possible. What I usually do is to provide all possible
arguments and check which ones are missing (via missing()) to determine
which to use to construct the object. Another possibility would be to
make the constructor a method which dispatches on the parameter types.

3. S4 methods can be debugged with trace(), to which a method name and a
signature can be passed. I think there is an item in the FAQ about this.
There is one peculiarity with debugging if you have a method that has
additional arguments compared to the generic, for example:

setGeneric(myMethod, function(x, ...) standardGeneric(myMethod))
setMethod(myMethod, myClassA, function(x,y) {myMethodA})

In this case, the implementation for myMethod will define and call an
inner function .local. In order to trace into this function, you have
to call debug(.local) from the browser once the method has been traced.


Hope this helps,

Andreas



A Zege schrieb:

Apologies for asking something that is probably super obvious, i just started
with S4 classes and i guess i am not finding documentation that layout the
grammar rules and give enough examples. Some questions i am having are these

1. I understand that main method of writing a member function is to write a
generic function and setMethod for this particular object. This, however,
presumes that there is virtuality for this function, i.e. it could be used
with other inherited classes . Truth is, many, if not most of my functions
don't have virtuality in mind. I want to write them inside classes to
achieve incapsulaton only -- use class member data without passing it as
parameters or making global to a bunch of functions and have some specific
class member functions that don't pollute a global namespace and can be
called only for a particular class. This is what i know how to do with
enclosures in R. Is there some obvious way of setting this environment local
to a class without writing generic functions that i am missing?

2. Is it possible to overload functions in other ways than having default
parameter values and prototypes?
For example, can i have  two constructors with completely different sets of
parameters?

3. Is there some good way to debug S4 classes? I am very fond of mtrace()
from debug package, but the simple set of commands i normally use doesn't
take me into class methods. 



Would appreciate any pointers on these..


--
View this message in context: 
http://r.789695.n4.nabble.com/super-basic-questions-about-S4-classes-tp3428591p3428591.html
Sent from the R devel mailing list archive at Nabble.com.

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

  



--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und

Re: [Rd] Feature request: txtProgressBar with ability to write to arbitrary stream

2011-03-16 Thread Andreas Borg
Thanks for all the suggestions. However, I was not really looking for a 
solution but I want to propose this (in my view useful) change to be 
included in a future version of R. For the time being I will include a 
modified version in my package.


Best regards,

Andreas


--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] Feature request: txtProgressBar with ability to write to arbitrary stream

2011-03-15 Thread Andreas Borg

Hi all,

I use txtProgressBar to monitor progress of large computations. What I 
miss is the ability to redirect the progress bar to a stream other than 
stdout, specifically to the message stream. This would be useful for 
running Sweave scripts: When redirected to stderr, the bar could be 
visible even though console output is diverted to the output file (and 
there would be no cluttering of the generated latex).


I'd suggest the following changes to txtProgressBar:
- a new argument 'file' (compare to 'cat') which defaults to stderr() 
(there might be reasons to use stdout(), but I believe a progress bar is 
mostly intended as a diagnostic tool and not for console output, which 
is printed or saved in some cases).
- the calls to 'cat' that update the progress bar get 'file = file' as 
additional argument so that output is redirected as desired.


In case anyone from the core team is willing to incorparate this idea, I 
attached the patch file for the necessary changes below.


Best regards,

Andreas

3c3
  width = NA, title, label, style = 1)
---
  width = NA, title, label, style = 1, file=stderr())
23c23
 cat(paste(rep.int(char, nb-.nb), collapse=))
---
 cat(paste(rep.int(char, nb-.nb), collapse=), file = file)
27c27
 \r, paste(rep.int(char, nb), collapse=), sep = )
---
 \r, paste(rep.int(char, nb), collapse=), sep = 
, file = file)

38c38
 cat(\r, paste(rep.int(char, nb), collapse=), sep = )
---
 cat(\r, paste(rep.int(char, nb), collapse=), sep = 
, file = file)

42c42
 \r, paste(rep.int(char, nb), collapse=), sep = )
---
 \r, paste(rep.int(char, nb), collapse=), sep = 
, file = file)

54c54
 cat(paste(c(\r  |, rep.int( , nw*width+6)), collapse=))
---
 cat(paste(c(\r  |, rep.int( , nw*width+6)), collapse=), 
file = file)

59c59
 ), collapse=))
---
 ), collapse=), file = file)
68c68
 cat(\n)
---
 cat(\n, file = file)

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] Using missing() in a S4 method with extra arguments

2011-03-11 Thread Andreas Borg

Hi all,

I have a function which makes use of missing() to determine which 
arguments are provided in the call - basically, there are two sets of 
arguments that map to different strategies the function uses to fulfill 
its task. After conversion to an S4 generic I've run into the problem 
that if a method uses extra arguments that are not in the signature of 
the generic, usage of missing() fails. The following example exemplifies 
this:


   setGeneric(fun, function(x=0, y=0, ...) standardGeneric(fun))
   # both methods should output if the second argument is missing
   setMethod(fun, character, function(x=0, y=0, ...) missing(y))
   setMethod(fun, numeric, function(x=0, y=0, z=0, ...) missing(y))

   fun(a) # this works fine
   fun(1) # this gives FALSE

I've understood so far that this is due to the fact that the numeric 
method in this example is rewritten to:


   function (x = 0, y = 0, ...)
   {
   .local - function (x = 0, y = 0, z = 0, ...)
   missing(y)
   .local(x, y, ...)
   }

The call to .local evaluates y and it is no more missing.

Is there any alternative that works in this case? Or is there a chance 
that missing() might be changed to work in this case in the near future?


Of course I know I could set NA or NULL as default values and check for 
these, but there are reasons I want to have legal default values for all

arguments.

Best regards,

Andreas

Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


Re: [Rd] Using missing() in a S4 method with extra arguments

2011-03-11 Thread Andreas Borg

Hi Martin,

in the real function, I am not dispatching on the argument for which I 
test missingness, but it might be a good idea to do so - this way I 
could make the function tidier by relocating different branches to 
seperate methods. Thanks for the suggestion!


Andreas



if you're testing for the missing-ness of y, and y is in the function
signature, then use that for dispatch

   setMethod(fun, c(character, missing),
 function(x=0, y=0, z=0, ...) missing)
   setMethod(fun, c(character, ANY),
 function(x=0, y=0, z=0, ...) not missing)

Since you're dispatching on x and y, it doesn't really make sense (to me
;) to assign default values to them. Testing for missing-ness of z would
I think have to rely on NA / NULL or other sentinel.

Martin
  


--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] Problem with documentation of user-defined operator (S4 method)

2011-02-21 Thread Andreas Borg

Dear list members,

I have defined a binary operator %append% with methods for some S4 
classes. In my documentation file, I want to list the methods explicitly 
by using e.g.:


   \S4method{\%append\%}{RecLinkData,RecLinkData}(x, y)

In the HTML documentation this comes out right as
  
   ## S4 method for signature 'RecLinkResult,RecLinkResult'

   x %append% y

, but R CMD check raises the following warning:

   Bad \usage lines found in documentation object '%append%-methods':
 unescaped bkslS4method{%append%}{RecLinkData,RecLinkData}(x, y)

Any idea what is wrong?

I have seen this behaviour with R 2.12.0 and 2.12.1.

Best regards and thanks for any suggestion,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


Re: [Rd] Problem with documentation of user-defined operator (S4 method)

2011-02-21 Thread Andreas Borg

Just to add this, the operator is defined as follows:

standardGeneric for %append% defined from package RecordLinkage

function (x, y)
standardGeneric(%append%)
environment: 01b19a3c
Methods may be defined for arguments: x, y
Use  showMethods(%append%)  for currently available ones.

So this is not a problem of misspelled arguments. The involved class is 
an S3 class made usable to S4 methods by oldClass.


Andreas Borg schrieb:

Dear list members,

I have defined a binary operator %append% with methods for some S4 
classes. In my documentation file, I want to list the methods 
explicitly by using e.g.:


   \S4method{\%append\%}{RecLinkData,RecLinkData}(x, y)

In the HTML documentation this comes out right as
 ## S4 method for signature 'RecLinkResult,RecLinkResult'
   x %append% y

, but R CMD check raises the following warning:

   Bad \usage lines found in documentation object '%append%-methods':
 unescaped bkslS4method{%append%}{RecLinkData,RecLinkData}(x, y)

Any idea what is wrong?

I have seen this behaviour with R 2.12.0 and 2.12.1.

Best regards and thanks for any suggestion,

Andreas




--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


Re: [Rd] Package with multiple shared libraries

2010-11-16 Thread Andreas Borg
Thanks for your reply. Actually my problem is not how to install the 
libraries in the sense of copying them to the right place, but how to 
build more than one .so or .dll file. Anyway, I did read the code and 
found that absence of a Makefile, a single library is built from all 
source files in directory src:


 srcs - dir(pattern = \\.([cfmM]|cc|cpp|f90|f95|mm)$)

 [...]

 has_error - run_shlib(pkg_name, srcs,
   instdir, )

where the last call basically executes R CMD SHLIB on the sources.

So a custom Makefile seems the only feasible solution. Still I'd be 
thankful to know about other packages (if they exist) which create other 
than the standard library files.


Best regards,

Andreas

Prof Brian Ripley schrieb:
R CMD INSTALL is R code, and you can read it for yourself rather than 
asking other people to do so for you.  If you look in

tools:::.install.packages you will see

shlib_install - function(instdir, arch)
{
files - Sys.glob(paste0(*, SHLIB_EXT))
if (length(files)) {
...

so it does in general install all the *.so or *.dll's generated.  I am 
not aware of a package that does so for more than one, though.


On Mon, 15 Nov 2010, Andreas Borg wrote:


Dear R-devel members,

I would like to compile a package with two seperate shared libraries. 
For example, in a package 'foo', a file 'bar.so' built from a 
distinct set of source files should be installed in addition to the 
default 'foo.so' (or .dll on windows). Does anyone know about a way 
to achieve this without having a custom Makefile, e.g. via 'Makevars'?


Also, I'd be thankful for information on existing packages which make 
use of this or a similar customization.


Just in case anyone is interested in details: I have some C-code 
which is not intended to be loaded into R but into a SQLite database 
to which I connect via RSQLite. I would like to have these object in 
a seperate library.


In which case it seems that the library should not be in the package's 
libs directory, which is intended for DSO/DLLs to be loaded into R.


If you want to do this in a public package you need to remember that 
multiple architectures are used on Mac OS and Windows.



Thanks and kind regards,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de





--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] Package with multiple shared libraries

2010-11-15 Thread Andreas Borg

Dear R-devel members,

I would like to compile a package with two seperate shared libraries. 
For example, in a package 'foo', a file 'bar.so' built from a distinct 
set of source files should be installed in addition to the default 
'foo.so' (or .dll on windows). Does anyone know about a way to achieve 
this without having a custom Makefile, e.g. via 'Makevars'?


Also, I'd be thankful for information on existing packages which make 
use of this or a similar customization.


Just in case anyone is interested in details: I have some C-code which 
is not intended to be loaded into R but into a SQLite database to which 
I connect via RSQLite. I would like to have these object in a seperate 
library.


Thanks and kind regards,

Andreas

--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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


[Rd] Fix for bug in match()

2010-01-18 Thread Andreas Borg

Hello all,

I posted the following bug last week:

# These calls work correctly:
match(c(A, B, C), c(A,C), incomparables=NA) # okay
match(c(A, B, C), A) # okay
match(A, c(A, B), incomparables=NA) # okay

# This one causes R to hang:
match(c(A, B, C), A, incomparables=NA)

I found the reason in the hash table implementation in unique.c. Values 
in the table argument of match are stored in a hash table. Incomparables 
are then removed by (potentially multiple) calls to removeEntry():


static void removeEntry(SEXP table, SEXP x, int indx, HashData *d)
{
   int i, *h;

   h = INTEGER(d-HashTable);
   i = d-hash(x, indx, d);
   while (h[i] != NIL) {
   if (d-equal(table, h[i], x, indx)) {
   h[i] = NA_INTEGER;  /*  0, only index values are inserted */
   return;
   }
   i = (i + 1) % d-M;
   }
   h[i] = NA_INTEGER;
}

Removing a value x sets the corresponding cell to NA_INTEGER. If x is 
not element of the table, the cell where it would have been is set from 
NIL (-1) to NA_INTEGER. Therefore, subsequent calls to removeEntry() 
with values that are not element of the table can remove all initial NIL 
values from the table cells. Another call of removeEntry() or Lookup() 
then leads to an infinte loop because the condition


while (h[i] != NIL)

is never false.

As a fix, I propose to reset cells to NIL when removing values, which 
leads to the following definition:


static void removeEntry(SEXP table, SEXP x, int indx, HashData *d)
{
   int i, *h;

   h = INTEGER(d-HashTable);
   i = d-hash(x, indx, d);
   while (h[i] != NIL) {
   if (d-equal(table, h[i], x, indx)) {
   h[i] = NIL;  /*  0, only index values are inserted */
   return;
   }
   i = (i + 1) % d-M;
   }
}

I would have submitted a patch file, but I couldn't checkout from the 
svn repository.


Cheers,

Andreas





--
Andreas Borg
Medizinische Informatik

UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de

Telefon +49 (0) 6131 175062
E-Mail: b...@imbei.uni-mainz.de

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. 
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren 
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die 
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.

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