Re: [Rd] core Matrix package segfaulted on R CMD check --use-gct

2011-04-08 Thread peter dalgaard
(Resending with fewer recipients...)

On Apr 8, 2011, at 07:09 , Hin-Tak Leung wrote:

 --- On Fri, 8/4/11, peter dalgaard pda...@gmail.com wrote:
 
 On Apr 7, 2011, at 23:57 , Hin-Tak Leung wrote:
 
 
 Oh, I am tracking both R and Matrix via git-svn and
 retrieves all revisions to all branches daily (or at least,
 regularly). I.e. R svn head.  2.13.0 only forked off
 recently and most of the trunk-2.13.0rc differences
 are so far mostly documentation-related. I could switch to
 track R 2.13.x branch if you insist.
 
 
 Please do. It's the branch that is supposed to stabilize
 during prerelease times.
 
 Also, please check the prerelease tarballs, errors in make
 dist are not caught when building from svn.
 
 Just so that there is no doubt, here is the recipe with the latest rc tar 
 ball, cutting-and-pasting from my command history:

Thanks. I wasn't expecting things to be different, just making a point about 
checking the right object. In principle, we could be putting in unstable 
development code in the trunk as soon as the branch was made.

 wget -m 
 http://cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
 cd /tmp
 tar -zxpvf 
 ~/cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
 cd R-rc/
 export DEFS='-DUSE_TYPE_CHECKING_STRICT -DR_MEMORY_PROFILING' ; ./configure  
 --enable-memory-profiling --enable-strict-barrier 
 --enable-byte-compiled-packages

Aha... Does it happen without --enable-byte-compiled-packages? To quote NEWS:

by default the compiler is not used in this release

so bugs in the compiler are interesting, but not release-critical.

 --with-valgrind-instrumentation=2  ; make
 cd src/library/
 cd Recommended/
 ../../../bin/R CMD check --use-gct Matrix_0.999375-49.tar.gz
 
 --
 ...
 Running examples in ‘Matrix-Ex.R’ failed
 The error occurred in:
 
 
 R version 2.13.0 RC (2011-04-07 r55373)
 Copyright (C) 2011 The R Foundation for Statistical Computing
 ISBN 3-900051-07-0
 Platform: x86_64-unknown-linux-gnu (64-bit)
 ...
 pkgname - Matrix
 source(file.path(R.home(share), R, examples-header.R))
 gctorture(TRUE)
 options(warn = 1)
 library('Matrix')
 Loading required package: lattice
 Error in regexpr(package:, envName, fixed = TRUE) : 
 unprotected object (0x3be2ba8) encountered (was INTSXP)
 Error: package/namespace load failed for 'Matrix'
 Execution halted
 -
 

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

__
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 

Re: [Rd] core Matrix package segfaulted on R CMD check --use-gct

2011-04-08 Thread Prof Brian Ripley

On Fri, 8 Apr 2011, peter dalgaard wrote:


(Resending with fewer recipients...)

On Apr 8, 2011, at 07:09 , Hin-Tak Leung wrote:


--- On Fri, 8/4/11, peter dalgaard pda...@gmail.com wrote:


On Apr 7, 2011, at 23:57 , Hin-Tak Leung wrote:



Oh, I am tracking both R and Matrix via git-svn and

retrieves all revisions to all branches daily (or at least,
regularly). I.e. R svn head.  2.13.0 only forked off
recently and most of the trunk-2.13.0rc differences
are so far mostly documentation-related. I could switch to
track R 2.13.x branch if you insist.




Please do. It's the branch that is supposed to stabilize
during prerelease times.

Also, please check the prerelease tarballs, errors in make
dist are not caught when building from svn.


Just so that there is no doubt, here is the recipe with the latest rc tar ball, 
cutting-and-pasting from my command history:


Thanks. I wasn't expecting things to be different, just making a 
point about checking the right object. In principle, we could be 
putting in unstable development code in the trunk as soon as the 
branch was made.


And despite claims to the contrary earlier in this thread, we 
certainly did.  (One example was in regexpr, although not AFAICS in a 
code branch used in this issue.)  Once 2.x.0 branches, the trunk 
becomes a playpen for ideas considered too radical/experimental for a 
release a month or two off.



wget -m 
http://cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
cd /tmp
tar -zxpvf 
~/cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
cd R-rc/


export DEFS='-DUSE_TYPE_CHECKING_STRICT -DR_MEMORY_PROFILING' ; 
./configure --enable-memory-profiling --enable-strict-barrier 
--enable-byte-compiled-packages


Note that the first define does nothing and the second just repeats 
what --enable-memory-profiling does.  Neither are documented in 
current R AFAICS.



Aha... Does it happen without --enable-byte-compiled-packages? To quote NEWS:

by default the compiler is not used in this release

so bugs in the compiler are interesting, but not release-critical.


But --enable-byte-compiled-packages does nothing, as configure --help 
says in 2.13.0 RC (and AFAICS it is documented nowhere else).


You really can't asumme that things not described in the R-admin 
manual are actually relevant to R (or current R).  autoconf puts 
things in configure that are boilerplate code we do not use (and I've 
tried to indicate which ones come from libtool or libintl).



--with-valgrind-instrumentation=2  ; make
cd src/library/
cd Recommended/
../../../bin/R CMD check --use-gct Matrix_0.999375-49.tar.gz

--
...
Running examples in ‘Matrix-Ex.R’ failed
The error occurred in:


R version 2.13.0 RC (2011-04-07 r55373)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
...

pkgname - Matrix
source(file.path(R.home(share), R, examples-header.R))
gctorture(TRUE)
options(warn = 1)
library('Matrix')

Loading required package: lattice
Error in regexpr(package:, envName, fixed = TRUE) :
unprotected object (0x3be2ba8) encountered (was INTSXP)
Error: package/namespace load failed for 'Matrix'
Execution halted
-



--
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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



--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] Invalid connection after closing?

2011-04-08 Thread Joris Meys
Dear all,

I do not completely understand following behaviour :

 con - file(test.txt)
 isOpen(con)
[1] FALSE
 open(con)
 isOpen(con)
[1] TRUE
 close(con)
 isOpen(con)
Error in isOpen(con) : invalid connection
 str(con)
Classes 'file', 'connection'  atomic [1:1] 3
  ..- attr(*, conn_id)=externalptr

Why do I get an error, indicating an invalid connection, after I
closed a connection? Is this to be expected?
Cheers
Joris

-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


[Rd] duplicates() function

2011-04-08 Thread Duncan Murdoch
I need a function which is similar to duplicated(), but instead of 
returning TRUE/FALSE, returns indices of which element was duplicated.  
That is,


 x - c(9,7,9,3,7)
 duplicated(x)
[1] FALSE FALSE  TRUE FALSE TRUE

 duplicates(x)
[1] NA NA  1 NA  2

(so that I know that element 3 is a duplicate of element 1, and element 
5 is a duplicate of element 2, whereas the others were not duplicated 
according to our definition.)


Is there a simple way to write this function?  I have  an ugly 
implementation in R that loops over all the values; it would make more 
sense to redo it in C, if there isn't a simple implementation I missed.


Duncan Murdoch

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


Re: [Rd] duplicates() function

2011-04-08 Thread Joshua Ulrich
How about:

y - rep(NA,length(x))
y[duplicated(x)] - match(x[duplicated(x)] ,x)

--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
 I need a function which is similar to duplicated(), but instead of returning
 TRUE/FALSE, returns indices of which element was duplicated.  That is,

 x - c(9,7,9,3,7)
 duplicated(x)
 [1] FALSE FALSE  TRUE FALSE TRUE

 duplicates(x)
 [1] NA NA  1 NA  2

 (so that I know that element 3 is a duplicate of element 1, and element 5 is
 a duplicate of element 2, whereas the others were not duplicated according
 to our definition.)

 Is there a simple way to write this function?  I have  an ugly
 implementation in R that loops over all the values; it would make more sense
 to redo it in C, if there isn't a simple implementation I missed.

 Duncan Murdoch

 __
 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] Invalid connection after closing?

2011-04-08 Thread Duncan Murdoch

On 08/04/2011 10:56 AM, Joris Meys wrote:

Dear all,

I do not completely understand following behaviour :

  con- file(test.txt)
  isOpen(con)
[1] FALSE
  open(con)
  isOpen(con)
[1] TRUE
  close(con)
  isOpen(con)
Error in isOpen(con) : invalid connection
  str(con)
Classes 'file', 'connection'  atomic [1:1] 3
   ..- attr(*, conn_id)=externalptr

Why do I get an error, indicating an invalid connection, after I
closed a connection? Is this to be expected?


Quoting ?close:  ‘close’ closes and destroys a connection.  In the 
current implementation, connections are a finite resource, and you need 
to be able to get rid of them when you are done. close(con) is the way 
to do that. If you want to re-open it, you need to remember the filename 
(or extract it before calling close()), and issue another call to file().


Duncan Murdoch

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


Re: [Rd] duplicates() function

2011-04-08 Thread Hadley Wickham
On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
 I need a function which is similar to duplicated(), but instead of returning
 TRUE/FALSE, returns indices of which element was duplicated.  That is,

 x - c(9,7,9,3,7)
 duplicated(x)
 [1] FALSE FALSE  TRUE FALSE TRUE

 duplicates(x)
 [1] NA NA  1 NA  2

 (so that I know that element 3 is a duplicate of element 1, and element 5 is
 a duplicate of element 2, whereas the others were not duplicated according
 to our definition.)

 Is there a simple way to write this function?  I have  an ugly
 implementation in R that loops over all the values; it would make more sense
 to redo it in C, if there isn't a simple implementation I missed.

I'd think of making it a lookup table.  The basic idea is

split(seq_along(x), x)

but there are probably much faster ways of doing it, depending on what
you need.  But for efficiency, you probably need a hashtable
somewhere.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [Rd] Invalid connection after closing?

2011-04-08 Thread Joris Meys
Thx for the information. I read it, but I wasn't sure what was going
on inside. Is there a way to close a connection without destroying it?
Guess not, but you never know...

Cheers
Joris

On Fri, Apr 8, 2011 at 5:09 PM, Duncan Murdoch murdoch.dun...@gmail.com wrote:
 On 08/04/2011 10:56 AM, Joris Meys wrote:

 Dear all,

 I do not completely understand following behaviour :

   con- file(test.txt)
   isOpen(con)
 [1] FALSE
   open(con)
   isOpen(con)
 [1] TRUE
   close(con)
   isOpen(con)
 Error in isOpen(con) : invalid connection
   str(con)
 Classes 'file', 'connection'  atomic [1:1] 3
   ..- attr(*, conn_id)=externalptr

 Why do I get an error, indicating an invalid connection, after I
 closed a connection? Is this to be expected?

 Quoting ?close:  ‘close’ closes and destroys a connection.  In the current
 implementation, connections are a finite resource, and you need to be able
 to get rid of them when you are done. close(con) is the way to do that. If
 you want to re-open it, you need to remember the filename (or extract it
 before calling close()), and issue another call to file().

 Duncan Murdoch




-- 
Joris Meys
Statistical consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

tel : +32 9 264 59 87
joris.m...@ugent.be
---
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

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


Re: [Rd] duplicates() function

2011-04-08 Thread Kasper Daniel Hansen
On Fri, Apr 8, 2011 at 11:08 AM, Joshua Ulrich josh.m.ulr...@gmail.com wrote:
 How about:

 y - rep(NA,length(x))
 y[duplicated(x)] - match(x[duplicated(x)] ,x)


I use Joshua's trick all the time.  But it might still be nice with a
C implementation.

While we are discussing duplication, I would also like to see
something like duplicated() but which returns TRUE whenever a value is
later duplicated, so I can easily select the values of a vector which
has are never duplicated.  Right now I need to do something like
  y [ ! y %in% y[duplicated(y)] ]
I am only bringing this up because of Duncan's request.

Kasper






 --
 Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



 On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdoch murdoch.dun...@gmail.com 
 wrote:
 I need a function which is similar to duplicated(), but instead of returning
 TRUE/FALSE, returns indices of which element was duplicated.  That is,

 x - c(9,7,9,3,7)
 duplicated(x)
 [1] FALSE FALSE  TRUE FALSE TRUE

 duplicates(x)
 [1] NA NA  1 NA  2

 (so that I know that element 3 is a duplicate of element 1, and element 5 is
 a duplicate of element 2, whereas the others were not duplicated according
 to our definition.)

 Is there a simple way to write this function?  I have  an ugly
 implementation in R that loops over all the values; it would make more sense
 to redo it in C, if there isn't a simple implementation I missed.

 Duncan Murdoch

 __
 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] How to debug reference classes?

2011-04-08 Thread A Zege
Thank you very much, gentlemen. It seems reference classes will make my life
much easier. I won't pretend that i fully understand the wizardry with
environments that you do, but it works :). Namely the steps to mtrace a
class method by doing what John and Mark outlined
   xx$edit-xx$edit
   mtrace(edit, from=xx)
   xx$edit(1,1,99)

do the magic of starting mtrace which solves my problem for practical
purposes. I was not able to make the second part of prescription related to
debugging unconstructed objects work. Namely, whenever i do 

 mtrace( edit, from=mEditor$def@refMethods) 

I get 
Error in parent.env(from) : the empty environment has no parent. Must be
doing something wrong, but haven't yet figured what.

--
View this message in context: 
http://r.789695.n4.nabble.com/How-to-debug-reference-classes-tp3434269p3436674.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


Re: [Rd] duplicates() function

2011-04-08 Thread Joshua Ulrich
On Fri, Apr 8, 2011 at 10:15 AM, Duncan Murdoch
murdoch.dun...@gmail.com wrote:
 On 08/04/2011 11:08 AM, Joshua Ulrich wrote:

 How about:

 y- rep(NA,length(x))
 y[duplicated(x)]- match(x[duplicated(x)] ,x)

 That's a nice solution for vectors.  Unfortunately for me, I have a matrix
 (which duplicated() handles by checking whole rows).  So a better example
 that I should have posted would be

 x -  cbind(1, c(9,7,9,3,7) )

 and I'd still like the same output

For a matrix, could you apply the same strategy used in duplicated()?

y - rep(NA,NROW(x))
temp - apply(x, 1, function(x) paste(x, collapse=\r))
y[duplicated(temp)] - match(temp[duplicated(temp)], temp)

  duplicated(x)

 [1] FALSE FALSE  TRUE FALSE TRUE

  duplicates(x)

 [1] NA NA  1 NA  2


 Duncan Murdoch

 --
 Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



 On Fri, Apr 8, 2011 at 9:59 AM, Duncan Murdochmurdoch.dun...@gmail.com
  wrote:
   I need a function which is similar to duplicated(), but instead of
  returning
   TRUE/FALSE, returns indices of which element was duplicated.  That is,
 
   x- c(9,7,9,3,7)
   duplicated(x)
   [1] FALSE FALSE  TRUE FALSE TRUE
 
   duplicates(x)
   [1] NA NA  1 NA  2
 
   (so that I know that element 3 is a duplicate of element 1, and element
  5 is
   a duplicate of element 2, whereas the others were not duplicated
  according
   to our definition.)
 
   Is there a simple way to write this function?  I have  an ugly
   implementation in R that loops over all the values; it would make more
  sense
   to redo it in C, if there isn't a simple implementation I missed.
 
   Duncan Murdoch
 
   __
   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] duplicates() function

2011-04-08 Thread William Dunlap
 -Original Message-
 From: r-devel-boun...@r-project.org 
 [mailto:r-devel-boun...@r-project.org] On Behalf Of Duncan Murdoch
 Sent: Friday, April 08, 2011 8:16 AM
 To: Joshua Ulrich
 Cc: R-devel@r-project.org
 Subject: Re: [Rd] duplicates() function
 
 On 08/04/2011 11:08 AM, Joshua Ulrich wrote:
  How about:
 
  y- rep(NA,length(x))
  y[duplicated(x)]- match(x[duplicated(x)] ,x)
 
 That's a nice solution for vectors.  Unfortunately for me, I have a 
 matrix (which duplicated() handles by checking whole rows).  

Does R have a function like match() that treats matrices
and data.frames row-wise, as duplicated() and unique() do?
duplicated() and match() do related things and I've been
annoyed that their methods for non-vectors do not match up
with each other.  (For historical reasons match cannot be
changed, but perhaps a new generic is in order.)

JU's code still would not work on matrices, but a variant could.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 


 So a better 
 example that I should have posted would be
 
 x -  cbind(1, c(9,7,9,3,7) )
 
 and I'd still like the same output
 
   duplicated(x)
 [1] FALSE FALSE  TRUE FALSE TRUE
 
   duplicates(x)
 [1] NA NA  1 NA  2
 
 
 Duncan Murdoch
 
  --
  Joshua Ulrich  |  FOSS Trading: www.fosstrading.com
 
 
 
  On Fri, Apr 8, 2011 at 9:59 AM, Duncan 
 Murdochmurdoch.dun...@gmail.com  wrote:
I need a function which is similar to duplicated(), but 
 instead of returning
TRUE/FALSE, returns indices of which element was 
 duplicated.  That is,
  
x- c(9,7,9,3,7)
duplicated(x)
[1] FALSE FALSE  TRUE FALSE TRUE
  
duplicates(x)
[1] NA NA  1 NA  2
  
(so that I know that element 3 is a duplicate of element 
 1, and element 5 is
a duplicate of element 2, whereas the others were not 
 duplicated according
to our definition.)
  
Is there a simple way to write this function?  I have  an ugly
implementation in R that loops over all the values; it 
 would make more sense
to redo it in C, if there isn't a simple implementation I missed.
  
Duncan Murdoch
  
__
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] core Matrix package segfaulted on R CMD check --use-gct

2011-04-08 Thread Hin-Tak Leung
--- On Fri, 8/4/11, peter dalgaard pda...@gmail.com wrote:

 On Apr 7, 2011, at 23:57 , Hin-Tak Leung wrote:
 
  
  Oh, I am tracking both R and Matrix via git-svn and
 retrieves all revisions to all branches daily (or at least,
 regularly). I.e. R svn head.  2.13.0 only forked off
 recently and most of the trunk-2.13.0rc differences
 are so far mostly documentation-related. I could switch to
 track R 2.13.x branch if you insist.
  
 
 Please do. It's the branch that is supposed to stabilize
 during prerelease times.
 
 Also, please check the prerelease tarballs, errors in make
 dist are not caught when building from svn.

Just so that there is no doubt, here is the recipe with the latest rc tar ball, 
cutting-and-pasting from my command history:

wget -m 
http://cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
cd /tmp
tar -zxpvf 
~/cran.r-project.org/src/base-prerelease/R-rc_2011-04-07_r55373.tar.gz
cd R-rc/
export DEFS='-DUSE_TYPE_CHECKING_STRICT -DR_MEMORY_PROFILING' ; ./configure  
--enable-memory-profiling --enable-strict-barrier 
--enable-byte-compiled-packages --with-valgrind-instrumentation=2  ; make
cd src/library/
cd Recommended/
../../../bin/R CMD check --use-gct Matrix_0.999375-49.tar.gz

--
...
Running examples in ‘Matrix-Ex.R’ failed
The error occurred in:


R version 2.13.0 RC (2011-04-07 r55373)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
...
 pkgname - Matrix
 source(file.path(R.home(share), R, examples-header.R))
 gctorture(TRUE)
 options(warn = 1)
 library('Matrix')
Loading required package: lattice
Error in regexpr(package:, envName, fixed = TRUE) : 
  unprotected object (0x3be2ba8) encountered (was INTSXP)
Error: package/namespace load failed for 'Matrix'
Execution halted
-


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


Re: [Rd] core Matrix package segfaulted on R CMD check --use-gct

2011-04-08 Thread peter dalgaard

On Apr 7, 2011, at 23:57 , Hin-Tak Leung wrote:

 
 Oh, I am tracking both R and Matrix via git-svn and retrieves all revisions 
 to all branches daily (or at least, regularly). I.e. R svn head.  2.13.0 only 
 forked off recently and most of the trunk-2.13.0rc differences are so far 
 mostly documentation-related. I could switch to track R 2.13.x branch if you 
 insist.
 

Please do. It's the branch that is supposed to stabilize during prerelease 
times.

Also, please check the prerelease tarballs, errors in make dist are not 
caught when building from svn.

-pd


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd@cbs.dk  Priv: pda...@gmail.com

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


Re: [Rd] question about assignment warnings for replacement methods

2011-04-08 Thread Hervé Pagès

Hi Duncan, Marc,

On 11-04-05 11:15 AM, Duncan Murdoch wrote:

On 05/04/2011 1:51 PM, Marc Carlson wrote:

Hi,

I have seen several packages that with the most recent version of R are
giving a warning like this:

Assignments in \usage in documentation object 'marginalData-methods':
marginalData(object) = value

I assume that this is to prevent people from making assignments in their
usage statements (which seems completely understandable). But what
about the case above? This is a person who just wants to show the
proper usage for a replacement method. IOW they just want to write
something that looks like what you actually do when you use a
replacement method. They just want to show users how to do something
like this:

replacementMethod(object)- newValue


So is that really something that should not be allowed in a usage
statement?


If replacementMethod was a replacement function, then

replacementMethod(object)- newValue

is supposed to be fine.


Yes, 'replacementMethod(object) - newValue' vorks indeed, but
not 'replacementMethod(object) = newValue'.


But if it is an S3 method, it should be

\method{replacementMethod}{class}(object)- newValue

and if it is an S4 method I think it should be

\S4method{replacementMethod}{signature_list}(object)- newValue


In the case reported by Marc, replacementMethod was both: a
replacement (generic) function and a replacement method. And the
man page had an alias for both. Marc replaced

  replacementMethod(object) = newValue

with

  \S4method{replacementMethod}{signature_list}(object)- newValue

and that solved the problem. But replacing '=' with '-' solves it too.

Shouldn't 'R CMD check' treat the 2 assignment operators the same way
since they are equivalent?

Thanks!
H.



(though the manual suggests using the S3 style, I'm not sure how
literally to take it).

Duncan Murdoch

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



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


Re: [Rd] question about assignment warnings for replacement methods

2011-04-08 Thread Simon Urbanek

On Apr 8, 2011, at 2:55 PM, Hervé Pagès wrote:

 Hi Duncan, Marc,
 
 On 11-04-05 11:15 AM, Duncan Murdoch wrote:
 On 05/04/2011 1:51 PM, Marc Carlson wrote:
 Hi,
 
 I have seen several packages that with the most recent version of R are
 giving a warning like this:
 
 Assignments in \usage in documentation object 'marginalData-methods':
 marginalData(object) = value
 
 I assume that this is to prevent people from making assignments in their
 usage statements (which seems completely understandable). But what
 about the case above? This is a person who just wants to show the
 proper usage for a replacement method. IOW they just want to write
 something that looks like what you actually do when you use a
 replacement method. They just want to show users how to do something
 like this:
 
 replacementMethod(object)- newValue
 
 
 So is that really something that should not be allowed in a usage
 statement?
 
 If replacementMethod was a replacement function, then
 
 replacementMethod(object)- newValue
 
 is supposed to be fine.
 
 Yes, 'replacementMethod(object) - newValue' vorks indeed, but
 not 'replacementMethod(object) = newValue'.
 
 But if it is an S3 method, it should be
 
 \method{replacementMethod}{class}(object)- newValue
 
 and if it is an S4 method I think it should be
 
 \S4method{replacementMethod}{signature_list}(object)- newValue
 
 In the case reported by Marc, replacementMethod was both: a
 replacement (generic) function and a replacement method. And the
 man page had an alias for both. Marc replaced
 
  replacementMethod(object) = newValue
 
 with
 
  \S4method{replacementMethod}{signature_list}(object)- newValue
 
 and that solved the problem. But replacing '=' with '-' solves it too.
 
 Shouldn't 'R CMD check' treat the 2 assignment operators the same way
 since they are equivalent?
 

They are not equivalent (you can't use = in many places where you can use -).

Also my understanding is that it is considered bad practice by some to use = as 
assignment outside of the command prompt (interactive use) -- but opinions vary 
and I don't want to start a flame war here ;).

Cheers,
Simon



 Thanks!
 H.
 
 
 (though the manual suggests using the S3 style, I'm not sure how
 literally to take it).
 
 Duncan Murdoch
 
 __
 R-devel@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-devel
 
 
 -- 
 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
 
 

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


[Rd] Consistency of messages from R CMD {check,build,install}

2011-04-08 Thread Michael Friendly
A minor gripe/request:  Could all R CMD package tools not at the very 
least be consistent in indicating when

they are done, as in
* DONE (packagename)
or at least
* DONE

R CMD build leaves one hanging, not knowing whether it has completed or 
it is time to get another coffee.


* checking for file 'C:/Documents/workspace/heplots/DESCRIPTION' ... OK
* preparing 'heplots':
* checking DESCRIPTION meta-information ... OK
* installing the package to re-build vignettes
* creating vignettes ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'heplots_0.9-8.tar.gz'

Some checking/building processes take a while, so it would also be nice 
if more of the info lines

ended with ... OK

tia,
-Michael


--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele StreetWeb:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA

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


[Rd] Compression of largish expression array files in the DAAGbio/inst/doc directory?

2011-04-08 Thread John Maindonald
The inst/doc directory of the DAAG package has 6 files coral551.spot, ... that
are around 0.85 MB each.  It would be useful to be able to zip then, but that
as matters stand interferes with the use of the Sweave file that uses them to
demonstrate input of expression array data that is in the spot format.  They
do not automatically get unzipped when required.  I have checked that 
read.maimages (in limma) does not, unless I have missed something, have 
an option for reading zipped files.  Is there any way to get around this without
substantially complicating the exposition in marray-notes.pdf (also in the
inst/doc subdirectory)?

John Maindonald email: john.maindon...@anu.edu.au
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics  Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.
http://www.maths.anu.edu.au/~johnm

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